fix(download): automatically degrade to single connection when server rejects chunked range bounds

When a server (like fuckingfast.co) ignores the upper bound of a range request (returning bytes=start-end/total), aria2 aborts with 'Invalid range header'. This patch treats that error as transient and mutates the download payload to force connections=1 before re-enqueuing. This ensures aria2 issues an open-ended range request (bytes=start-) on the retry, seamlessly resuming the download.
This commit is contained in:
NimBold
2026-06-29 22:13:26 +03:30
parent 20cbacd785
commit dbbfd5dc7c
2 changed files with 12 additions and 2 deletions
+9 -1
View File
@@ -492,6 +492,8 @@ impl<R: tauri::Runtime> QueueManager<R> {
}
}
log::error!("aria2 download {} failed: {}", id, error);
self.clear_aria2_retry_state(id).await;
self.forget_aria2_gid(id).await;
self.emit_failed(id, error);
@@ -630,7 +632,13 @@ impl<R: tauri::Runtime> QueueManager<R> {
.await;
return;
}
let payload = payload.unwrap();
let mut payload = payload.unwrap();
if error.to_ascii_lowercase().contains("invalid range header") {
log::warn!("Server does not support chunked ranges. Degrading {} to single connection.", id);
payload.connections = Some(1);
self.aria2_payloads.lock().await.insert(id.clone(), payload.clone());
}
let this = Arc::clone(self);
let stale_gid = gid.to_string();