From 7f8c72111532b9703e0c5748a0ee253e8d26458f Mon Sep 17 00:00:00 2001 From: spinline Date: Sat, 21 Feb 2026 01:27:22 +0300 Subject: [PATCH] debug: add tracing logs to set_file_priority for diagnosis --- shared/src/server_fns/torrent.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/shared/src/server_fns/torrent.rs b/shared/src/server_fns/torrent.rs index b998fe5..26f4ecf 100644 --- a/shared/src/server_fns/torrent.rs +++ b/shared/src/server_fns/torrent.rs @@ -225,20 +225,28 @@ pub async fn set_file_priority( let ctx = expect_context::(); let client = RtorrentClient::new(&ctx.scgi_socket_path); + tracing::info!( + "set_file_priority: hash={}, file_index={}, priority={}", + hash, file_index, priority + ); + + // rTorrent f.set_priority takes: target = "HASH:fINDEX", value = priority + // The target format for file commands is "HASH:f0", "HASH:f1", etc. let target = format!("{}:f{}", hash, file_index); let params = vec![ RpcParam::from(target.as_str()), RpcParam::from(priority as i64), ]; - client - .call("f.set_priority", ¶ms) - .await - .map_err(|e| ServerFnError::new(format!("RPC error: {}", e)))?; + let result = client.call("f.set_priority", ¶ms).await; + tracing::info!("f.set_priority result: {:?}", result); + result.map_err(|e| ServerFnError::new(format!("RPC error setting priority: {}", e)))?; - let _ = client + // Notify rTorrent to update its internal priority state + let update_result = client .call("d.update_priorities", &[RpcParam::from(hash.as_str())]) .await; + tracing::info!("d.update_priorities result: {:?}", update_result); Ok(()) }