mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-12 12:37:04 +00:00
fix(downloads): reconcile completed aria2 pause requests
This commit is contained in:
@@ -3272,6 +3272,22 @@ async fn pause_download(
|
|||||||
ensure_aria2_gid_result("forcePause", gid, &result)?;
|
ensure_aria2_gid_result("forcePause", gid, &result)?;
|
||||||
log::info!("aria2 pause [{}]: gid {} paused", id, gid);
|
log::info!("aria2 pause [{}]: gid {} paused", id, gid);
|
||||||
}
|
}
|
||||||
|
"complete" => {
|
||||||
|
// Aria2 can reach complete before its terminal event updates
|
||||||
|
// Firelink's row. Treat a pause request in that narrow window
|
||||||
|
// as an idempotent completion reconciliation, not as an
|
||||||
|
// actionable pause failure.
|
||||||
|
log::info!(
|
||||||
|
"aria2 pause [{}]: gid {} was already complete; reconciling completion",
|
||||||
|
id,
|
||||||
|
gid
|
||||||
|
);
|
||||||
|
state
|
||||||
|
.queue_manager
|
||||||
|
.apply_completion_locked(&id, crate::queue::PendingOutcome::Complete)
|
||||||
|
.await;
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
terminal => {
|
terminal => {
|
||||||
let retrying = state.queue_manager.has_aria2_retry_state(&id).await;
|
let retrying = state.queue_manager.has_aria2_retry_state(&id).await;
|
||||||
state.queue_manager.clear_aria2_retry_state(&id).await;
|
state.queue_manager.clear_aria2_retry_state(&id).await;
|
||||||
|
|||||||
@@ -774,10 +774,12 @@ impl<R: tauri::Runtime> QueueManager<R> {
|
|||||||
self.apply_completion_locked(id, outcome).await;
|
self.apply_completion_locked(id, outcome).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Apply a completion while the caller owns the download control lock.
|
/// Apply a terminal outcome while the caller owns the download control
|
||||||
/// Keeping the epoch transition and terminal cleanup under that lock
|
/// lock. Keeping the epoch transition and terminal cleanup under that
|
||||||
/// prevents an old WebSocket event from completing a newer lifecycle.
|
/// lock prevents an old WebSocket event from completing a newer lifecycle
|
||||||
async fn apply_completion_locked(&self, id: &str, outcome: PendingOutcome) {
|
/// and lets commands reconcile an Aria2 terminal status without releasing
|
||||||
|
/// the lock first.
|
||||||
|
pub(crate) async fn apply_completion_locked(&self, id: &str, outcome: PendingOutcome) {
|
||||||
// A terminal event invalidates every delayed retry or control worker
|
// A terminal event invalidates every delayed retry or control worker
|
||||||
// from the previous lifecycle before releasing its permit.
|
// from the previous lifecycle before releasing its permit.
|
||||||
self.next_aria2_control_epoch(id).await;
|
self.next_aria2_control_epoch(id).await;
|
||||||
|
|||||||
Reference in New Issue
Block a user