Fix pausing-resuming logic after queue reordering for concurrency >1 #20

Merged
maleszka merged 5 commits from fix/promoting into main 2026-07-06 22:03:27 +02:00
Owner

closes #17

closes #17
cancel_all() previously flipped one watch::channel<bool> shared by every
spawned worker, so pausing one entry to free its slot paused every active
download regardless of concurrency. spawn_pending now gives each worker its
own channel, and cancel_entry(id) signals exactly one. cancel_all() is kept,
reimplemented over the per-entry map, for the graceful-shutdown path that
genuinely needs every worker to stop.
DownloadQueue::overflow_ids(max_workers) finds Downloading entries pushed
past the active window by a reorder. DownloadSession::reconcile_active_window
cancels exactly those entries via cancel_entry, leaving every other in-flight
download untouched. Not yet wired into the interactive event loop.
pause_for_new_front only ever looked at index 0, so moving an entry into
the active window anywhere but the very front (concurrency > 1) never
paused the entry that should yield its slot. Replace it with
reconcile_active_window at all four reorder/remove call sites (J, K, d,
Enter). Per-entry cancellation from the previous two commits means
spawn_pending no longer needs the awaiting_promote_pause gate: an entry
mid-cancellation stays Downloading until its terminal message lands, so the
Pending|Paused scan already skips it. Drop the flag and the reset it required.
Promotes the per-entry cancellation model and active-window reconciliation
from the promoting feature spec: DownloadQueue::overflow_ids and
DownloadSession's cancel_entry/reconcile_active_window replace the retired
cancel_all-precondition/reset_cancel pair in the stable contract. Deletes
specs/features/promoting.md now that its contracts have graduated.
maleszka deleted branch fix/promoting 2026-07-06 22:03:27 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
maleszka/librespot-dl!20
No description provided.