fix(torrents): prevent unmanaged followed child GIDs

This commit is contained in:
NimBold
2026-08-02 22:55:13 +03:30
parent 7da67c15b5
commit d677f98dd1
3 changed files with 75 additions and 1 deletions
+16 -1
View File
@@ -23,11 +23,16 @@ pub(crate) enum ProbeFailure {
pub(crate) async fn run_metadata_probe<C: RpcClient + 'static>(
client: Arc<C>,
source: &str,
options: Map<String, Value>,
mut options: Map<String, Value>,
metadata_path: &Path,
timeout: Duration,
poll_interval: Duration,
) -> Result<Vec<u8>, ProbeFailure> {
// This probe only resolves magnet metadata. It must never allow Aria2 to
// interpret a downloaded metadata file as another child download because
// the probe cleanup guard owns exactly one GID.
options.insert("follow-torrent".to_string(), json!("false"));
options.insert("follow-metalink".to_string(), json!("false"));
let mut cleanup_guard = ProbeCleanupGuard::new(Arc::clone(&client), metadata_path);
let result = match client
.call("aria2.addUri", json!([[source], options]))
@@ -1018,6 +1023,16 @@ mod tests {
Some(&json!("true")),
"recorded addUri params: {add_params:?}"
);
assert_eq!(
options.get("follow-torrent"),
Some(&json!("false")),
"recorded addUri params: {add_params:?}"
);
assert_eq!(
options.get("follow-metalink"),
Some(&json!("false")),
"recorded addUri params: {add_params:?}"
);
tokio::fs::remove_dir_all(&probe_dir)
.await
.expect("successful probe fixture should be removable");