mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-27 19:17:13 +00:00
fix(download): honor retry and queue limits
Treat max_tries as the configured retry count instead of total attempts across native, media, aria2, and fallback paths. Route queue slot acquisition through retirement-aware permit handling so shrinking concurrency does not dispatch new work while active transfers still meet the smaller limit. Update retry-budget and queue-manager tests to cover the corrected attempt counts and paused aria2 resume behavior.
This commit is contained in:
+5
-10
@@ -2472,9 +2472,7 @@ pub(crate) async fn start_media_download_internal(
|
||||
let config_path = config_file.into_temp_path();
|
||||
|
||||
use crate::ipc::DownloadStateEvent;
|
||||
use crate::retry::{
|
||||
backoff_and_emit_cancel, is_transient_network_error, BackoffOutcome, MAX_RETRIES,
|
||||
};
|
||||
use crate::retry::{backoff_and_emit_cancel, is_transient_network_error, BackoffOutcome};
|
||||
|
||||
const STDERR_TAIL: usize = 2048;
|
||||
|
||||
@@ -2504,10 +2502,11 @@ pub(crate) async fn start_media_download_internal(
|
||||
// user-installed tools, or platform-specific executable aliases.
|
||||
let trusted_path = crate::platform::trusted_system_path()?;
|
||||
|
||||
let max_retries = max_tries.unwrap_or(0).max(0) as usize;
|
||||
let mut strike = 0_usize;
|
||||
let mut processing_started = false;
|
||||
|
||||
while strike <= MAX_RETRIES {
|
||||
while strike <= max_retries {
|
||||
let ytdlp_path = resolve_bundled_binary_path(&app_handle, "yt-dlp")?;
|
||||
let mut cmd = app_handle
|
||||
.shell()
|
||||
@@ -2520,7 +2519,7 @@ pub(crate) async fn start_media_download_internal(
|
||||
.arg("--socket-timeout")
|
||||
.arg("20")
|
||||
.arg("--retries")
|
||||
.arg("3")
|
||||
.arg(max_retries.to_string())
|
||||
.arg("--extractor-retries")
|
||||
.arg("3")
|
||||
.arg("--ffmpeg-location")
|
||||
@@ -2569,10 +2568,6 @@ pub(crate) async fn start_media_download_internal(
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(tries) = max_tries {
|
||||
cmd = cmd.arg("--retries").arg(tries.to_string());
|
||||
}
|
||||
|
||||
if let Some(loc) = config_location.as_ref() {
|
||||
cmd = cmd.arg("--config-location").arg(loc);
|
||||
}
|
||||
@@ -2781,7 +2776,7 @@ pub(crate) async fn start_media_download_internal(
|
||||
};
|
||||
|
||||
let transient = is_transient_network_error(&failure_reason);
|
||||
let strikes_left = strike < MAX_RETRIES;
|
||||
let strikes_left = strike < max_retries;
|
||||
if !(transient && strikes_left) {
|
||||
return Err(failure_reason);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user