From c215fdd658c8588716c0f8fc61137b18067a5808 Mon Sep 17 00:00:00 2001 From: Sucukdeluxe Date: Tue, 24 Mar 2026 09:29:01 +0100 Subject: [PATCH] Preserve selected-only run scope across stop/start cycles When startItems() was used with a subset of items (e.g. 2000 of 6020), stopping and restarting would pick up ALL 6020 queued items instead of just the original 2000. Now stop() marks items outside the run set as "Gestoppt" so they are not automatically included in the next start(). Co-Authored-By: Claude Opus 4.6 (1M context) --- src/main/download-manager.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/download-manager.ts b/src/main/download-manager.ts index bc8af47..ac4acbc 100644 --- a/src/main/download-manager.ts +++ b/src/main/download-manager.ts @@ -4551,13 +4551,23 @@ export class DownloadManager extends EventEmitter { active.abortReason = "stop"; active.abortController.abort("stop"); } - // Reset all non-finished items to clean "Wartet" / "Paket gestoppt" state + // Reset non-finished items. Items that were part of the current run + // (runItemIds) go back to "Wartet" so they are picked up by the next start(). + // Items that were NOT in the run set are marked "Gestoppt" so a subsequent + // start() does not accidentally include the entire queue. + const hadRunItems = this.runItemIds.size > 0; for (const item of Object.values(this.session.items)) { if (!isFinishedStatus(item.status)) { - item.status = "queued"; - item.speedBps = 0; const pkg = this.session.packages[item.packageId]; - item.fullStatus = pkg && !pkg.enabled ? "Paket gestoppt" : "Wartet"; + const wasInRun = !hadRunItems || this.runItemIds.has(item.id); + if (wasInRun) { + item.status = "queued"; + item.fullStatus = pkg && !pkg.enabled ? "Paket gestoppt" : "Wartet"; + } else { + item.status = "cancelled"; + item.fullStatus = "Gestoppt"; + } + item.speedBps = 0; item.updatedAt = nowMs(); } }