Skip to content

fix: download queue scheduling and stuck states - #302

Merged
fraa2a merged 4 commits into
mainfrom
fix/download-queue-scheduling
Nov 6, 2026
Merged

fraa2a merged 4 commits into
mainfrom
fix/download-queue-scheduling

Conversation

@fraa2a

@fraa2a fraa2a commented Nov 6, 2026

Copy link
Copy Markdown
Owner

What changed?

Four download queue fixes from the review, one commit each:

  • H2, queue running before startup recovery: the starting guard now starts true; kick() is a no-op until start() finishes recovery and clears it. The test_app fixture clears it so existing tests are unaffected.
  • H3, removed update target made sync fail and the queue restart in a loop: in download_policy::sync, an unavailable target (game removed or folder unreadable) now fails only that game's update jobs ("Update target is unavailable: ...") and interrupts a running transfer; other jobs continue.
  • H1, policy and staging waking each other in a tight loop: the staging task notifies the policy only when it actually changed something (staged, installed, or saved a failure). Deferred extraction/install is retried on the existing 1s policy tick. Failures are announced after the error is saved.
  • downloaded job with an error was stuck: Retry clears the error and re-runs staging; Remove is allowed when no staging task is active. Frontend canRetryDownload / canRemoveDownload updated; Remove still goes through the confirmation dialog.

Known limits (follow-ups): remove_game does not refuse while updates are pending; if sync fails for other reasons (e.g. DB error) run_queue still restarts without backoff; this state still can't be cancelled, only retried or removed.

No textual conflicts with #301 (checked with git merge-tree).

Validation

  • cargo test 967 passed, 0 failed, 4 ignored; clippy and fmt clean.
  • npm run check, npm run lint, npm run test:launcher (15) pass.
  • New tests: kick_waits_for_startup_recovery, removed_update_target_fails_only_its_job, idle_staging_does_not_wake_the_policy, removes_a_downloaded_entry_after_staging_failed, retry_stages_a_downloaded_entry_after_staging_failed.
  • Manual test in the running app.
  • No unrelated changes.

UI changes

Retry and Remove are now shown for downloaded jobs whose staging failed.


Generated by Claude Code

The starting guard in kick() was initialized to false and never armed, so
a frontend command could start a transfer before recovery reset
interrupted jobs. Arm it at construction; start() clears it after
recovery and then kicks the queue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DGbCKVdcUfJfjZ93bYY9p3
A pending update whose game was removed or whose folder is missing made
the download policy sync fail, which stopped and restarted the queue in a
loop. Mark only that update as failed with the reason instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DGbCKVdcUfJfjZ93bYY9p3
The staging task notified the policy loop even when it did nothing, so
while extraction or an update install was deferred the two woke each
other in a tight loop, scanning processes and emitting frontend events.
Notify only after staging, installing or a persisted failure; deferred
work is retried on the policy tick.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DGbCKVdcUfJfjZ93bYY9p3
A staging error raised before extraction started left the job downloaded
with an error, which is never scheduled again and could not be retried,
cancelled or removed. Retry now clears the error so the archive is staged
again, and removal is allowed once no staging task holds the job.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DGbCKVdcUfJfjZ93bYY9p3
@fraa2a
fraa2a merged commit c2a5b1c into main Nov 6, 2026
7 checks passed
@fraa2a
fraa2a deleted the fix/download-queue-scheduling branch November 6, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants