From 931e1f2f1eeb89c8e1e2d8ffad436671076030c0 Mon Sep 17 00:00:00 2001 From: NimBold Date: Sat, 25 Jul 2026 17:54:28 +0330 Subject: [PATCH] fix(queue): preserve aria2 connection pool --- src-tauri/src/queue.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src-tauri/src/queue.rs b/src-tauri/src/queue.rs index ee17e6d..23d0851 100644 --- a/src-tauri/src/queue.rs +++ b/src-tauri/src/queue.rs @@ -2395,6 +2395,7 @@ pub struct ProductionSpawner { } const ARIA2_MIN_SPLIT_SIZE: &str = "1M"; +const ARIA2_STREAM_PIECE_SELECTOR: &str = "inorder"; fn apply_aria2_connection_options( options: &mut serde_json::Map, @@ -2416,6 +2417,14 @@ fn apply_aria2_connection_options( "min-split-size".to_string(), serde_json::json!(ARIA2_MIN_SPLIT_SIZE), ); + // Aria2's default selector deliberately reduces the number of established + // connections over time. Keep a segmented HTTP transfer replenishing its + // requested ranges so a healthy host does not degrade from (for example) + // 16 active connections to one or two after early pieces finish. + options.insert( + "stream-piece-selector".to_string(), + serde_json::json!(ARIA2_STREAM_PIECE_SELECTOR), + ); } impl ProductionSpawner { @@ -2808,6 +2817,10 @@ mod tests { options.get("min-split-size"), Some(&serde_json::json!("1M")) ); + assert_eq!( + options.get("stream-piece-selector"), + Some(&serde_json::json!("inorder")) + ); } #[test]