Update-Neustart: laufende Downloads als queued parken statt als "Gestoppt" haengenzubleiben

Beim Update parkte installUpdate() aktive Downloads via stop() -> deren Abbruch-
Continuation markierte die Items "cancelled"/"Gestoppt". autoResumeOnStart nimmt
nach dem Neustart aber nur "queued"/"reconnect_wait" auf, also liefen die gerade
ladenden Downloads nach dem Update nicht weiter (timing-abhaengig: "manchmal").
Jetzt: stop({parkForRestart:true}) bricht aktive Tasks mit Grund "shutdown" ab,
sodass sie als "queued" re-queued werden (wie bei normalem App-Shutdown). Das
schliesst zugleich den einzigen plausiblen Loesch-Pfad (all-cancelled-Pakete sind
ueber applyRetroactiveCleanupPolicy entfernbar). Stop-Button-Verhalten unveraendert.

Zusaetzliche Robustheit in storage.ts (enge Blast-Radien, nicht die Hauptursache):
- async-Save-Clobber: eine gequeuete, veraltete Payload konnte einen neueren
  Sync-Save (persistNowSync/prepareForShutdown) ueberschreiben; Generation wird
  jetzt zum Snapshot-Zeitpunkt erfasst und durch die Queue getragen.
- loadSession gab leer zurueck (und ignorierte ein gefuelltes .bak), wenn die
  Primaerdatei fehlte; faellt jetzt auf die Backup/Temp-Recovery zurueck.

Regressionstests: tests/update-restart-resume.test.ts (echter Live-Download ->
Park -> Reload = queued, plus Charakterisierung plain stop() -> cancelled) und
tests/session-restart-loss.test.ts (Clobber + Backup-Fallback). Volle Suite gruen.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Sucukdeluxe
2026-06-02 05:19:54 +02:00
co-authored by Claude Opus 4.8
parent 53cc6b11eb
commit 8d03ca124f
5 changed files with 379 additions and 16 deletions
+8 -1
View File
@@ -440,8 +440,15 @@ public async checkDebridAccounts(): Promise<DebridAccountStatus[]> {
public async installUpdate(onProgress?: (progress: UpdateInstallProgress) => void): Promise<UpdateInstallResult> {
// Stop active downloads before installing. Extractions may continue briefly
// until prepareForShutdown() is called during app quit.
// parkForRestart MUST stay true here: it keeps in-flight items as "queued"
// (not "cancelled") so the updated app auto-resumes them after the silent
// install relaunch. A plain stop() marks them "cancelled"/"Gestoppt", which
// autoResumeOnStart does NOT pick up — the downloads then silently fail to
// continue after the update (the reported "packages gone after update" bug).
// Regression coverage: tests/update-restart-resume.test.ts asserts this exact
// stop({parkForRestart:true}) + persistNowSync() sequence reloads as "queued".
if (this.manager.isSessionRunning()) {
this.manager.stop();
this.manager.stop({ parkForRestart: true });
}
// Flush any pending async saves BEFORE the update process starts.
// This ensures the queue is fully persisted to disk so it survives the restart.