mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-09 10:49:29 +00:00
fix(queue): preserve lifecycle ownership during recovery
Require queue-permit ownership before resuming a paused GID and rebuild a job when its GID disappears during recovery. Advance the Browser companion with the automatic-capture handoff guard for #28.
This commit is contained in:
@@ -118,6 +118,10 @@ pub enum Aria2RecreateOutcome {
|
||||
Unavailable(String),
|
||||
}
|
||||
|
||||
fn aria2_recovery_should_rebuild_after_pause_error(status: &str) -> bool {
|
||||
status == "removed"
|
||||
}
|
||||
|
||||
/// What kind of sidecar a queued task spawns. Drives which runner the
|
||||
/// dispatcher invokes.
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -2824,6 +2828,16 @@ impl SidecarSpawner for ProductionSpawner {
|
||||
Ok(status) if status == "complete" => {
|
||||
return Ok(Aria2RecreateOutcome::Complete);
|
||||
}
|
||||
Ok(status)
|
||||
if aria2_recovery_should_rebuild_after_pause_error(&status) =>
|
||||
{
|
||||
log::warn!(
|
||||
"aria2 connection recovery [{}]: gid {} disappeared after forcePause failed; rebuilding from the saved payload: {}",
|
||||
id,
|
||||
gid,
|
||||
error
|
||||
);
|
||||
}
|
||||
Ok(status) => {
|
||||
return Err(format!(
|
||||
"failed to pause aria2 gid {gid} before recreation: {error}; daemon reports {status}"
|
||||
@@ -3128,6 +3142,13 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn aria2_recovery_rebuilds_when_force_pause_races_with_removal() {
|
||||
assert!(aria2_recovery_should_rebuild_after_pause_error("removed"));
|
||||
assert!(!aria2_recovery_should_rebuild_after_pause_error("paused"));
|
||||
assert!(!aria2_recovery_should_rebuild_after_pause_error("active"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn aria2_connection_options_clamp_untrusted_connection_counts() {
|
||||
let mut options = serde_json::Map::new();
|
||||
|
||||
Reference in New Issue
Block a user