diff --git a/package.json b/package.json index 3c92f88..c984350 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "real-debrid-downloader", - "version": "1.6.11", + "version": "1.6.12", "description": "Real-Debrid Downloader Desktop (Electron + React + TypeScript)", "main": "build/main/main/main.js", "author": "Sucukdeluxe", diff --git a/src/main/app-controller.ts b/src/main/app-controller.ts index 4f52864..5a8869b 100644 --- a/src/main/app-controller.ts +++ b/src/main/app-controller.ts @@ -161,7 +161,8 @@ export class AppController { } public async installUpdate(onProgress?: (progress: UpdateInstallProgress) => void): Promise { - // Stop active downloads/extractions before installing to avoid data corruption + // Stop active downloads before installing. Extractions may continue briefly + // until prepareForShutdown() is called during app quit. if (this.manager.isSessionRunning()) { this.manager.stop(); } @@ -294,9 +295,10 @@ export class AppController { this.settings = restoredSettings; saveSettings(this.storagePaths, this.settings); this.manager.setSettings(this.settings); - // Stop the manager BEFORE saving the restored session to prevent - // the auto-save timer from overwriting it with the old in-memory session. + // Full stop including extraction abort — the old session is being replaced, + // so no extraction tasks from it should keep running. this.manager.stop(); + this.manager.abortAllPostProcessing(); const restoredSession = parsed.session as ReturnType; saveSession(this.storagePaths, restoredSession); return { restored: true, message: "Backup wiederhergestellt. Bitte App neustarten." }; diff --git a/src/main/download-manager.ts b/src/main/download-manager.ts index ccf9bce..0348332 100644 --- a/src/main/download-manager.ts +++ b/src/main/download-manager.ts @@ -902,6 +902,14 @@ export class DownloadManager extends EventEmitter { return this.session.running; } + /** Abort all running post-processing tasks (extractions). */ + public abortAllPostProcessing(): void { + this.abortPostProcessing("external"); + for (const waiter of this.packagePostProcessWaiters) { waiter.resolve(); } + this.packagePostProcessWaiters = []; + this.packagePostProcessActive = 0; + } + /** Trigger pending extractions without starting the session (for autoExtractWhenStopped). */ public triggerIdleExtractions(): void { if (this.session.running || !this.settings.autoExtract || !this.settings.autoExtractWhenStopped) { @@ -6258,14 +6266,14 @@ export class DownloadManager extends EventEmitter { if (!this.session.packages[packageId]) { return; // Package was fully cleaned up } - pkg.status = (pkg.enabled && !this.session.paused) ? "downloading" : "paused"; + pkg.status = (pkg.enabled && this.session.running && !this.session.paused) ? "downloading" : "queued"; pkg.updatedAt = nowMs(); this.emitState(); return; } if (!allDone) { - pkg.status = (pkg.enabled && !this.session.paused) ? "downloading" : "paused"; + pkg.status = (pkg.enabled && this.session.running && !this.session.paused) ? "downloading" : "queued"; logger.info(`Post-Processing verschoben: pkg=${pkg.name}, noch offene items`); return; }