Scope cancelAllRequested to the run rather than to the drain

Clearing it when the last cancellation settles reopens a worse window than
it closes. A queue parked in WaitForDailyLimitAsync only re-reads the flag
every poll interval, so pressing Cancel All during a limit pause with
nothing in flight lets the drain finish and clear the flag well before the
gate wakes - it sees false and resumes the book that was just cancelled.

It is cleared in QueueLoop's finally instead, so it lasts exactly as long
as the run it belongs to. Queueing more work still withdraws an earlier
Cancel All, which is what AddToQueue's clear is for.
This commit is contained in:
Allamagoosa committed 2026-08-20 17:12:47 -07:00
1 parent d36369b321
commit 84c6f6fed0
1 file changed
+4 -1
@@ -652,7 +652,6 @@ public class ProcessQueueViewModel : ReactiveObject
Serilog.Log.Logger.Information("Begin processing queue");
_badBookSession.Reset();
cancelAllRequested = false;
dailyLimitMessageShownThisRun = false;
RunningTime = string.Empty;
ProgressBarVisible = true;
@@ -882,3 +881,7 @@ public class ProcessQueueViewModel : ReactiveObject
: $"{time.TotalHours:F0}:{time:mm\\:ss}";
}
}
// Scoped to the run, not to the drain. A queue parked in WaitForDailyLimitAsync only
// re-reads this every DailyLimitPollInterval, so clearing it when the last cancellation
// settles would let the gate wake up, see false, and resume the book just cancelled.
cancelAllRequested = false;