Harden download stop and restart lifecycle

Publish an explicit lifecycle snapshot with active download and post-processing counts. Guard asynchronous start recovery with a dedicated generation so a stop cannot revive an invalidated run. Keep starts requested during stopping pending until old work drains, then dispatch the accepted request once. Protect active task ownership and post-processing drain cleanup from stale finalizers. Cover recovery invalidation, pending restart dispatch, and late task cleanup with focused regression tests.
This commit is contained in:
Sucukdeluxe
2026-08-22 10:26:43 +02:00
parent 2e94484274
commit 1f97ce8b42
3 changed files with 346 additions and 47 deletions
+12
View File
@@ -655,6 +655,17 @@ export interface AccountRuntimeEntry {
dailyUsageBytes: number;
}
export type DownloadLifecyclePhase = "idle" | "starting" | "running" | "stopping" | "waiting_provider" | "postprocessing";
export interface DownloadLifecycleSnapshot {
phase: DownloadLifecyclePhase;
reason: string;
retryAt: number | null;
activeDownloads: number;
activePostProcessing: number;
pendingStart: boolean;
}
export interface UiSnapshot {
settings: RendererSettings;
accounts: RendererAccount[];
@@ -685,6 +696,7 @@ export interface UiSnapshot {
removedPackageIds?: string[];
rotationEvents?: RotationEvent[];
accountRuntime?: AccountRuntimeEntry[];
lifecycle?: DownloadLifecycleSnapshot;
}
export interface AddLinksPayload {