Fix downloads not starting: reset session.running on startup

Root cause: normalizeSessionStatuses() did not reset session.running
to false on startup. If the app was closed/crashed while downloads
were active, session.json retained running=true. On next launch,
start() checked if (this.session.running) return — silently refusing
to start any downloads.

Also improved normalizeSessionStatuses to match the old DM behavior:
- Reset session.running, paused, reconnectUntil, reconnectReason
- Recover cancelled/Gestoppt items back to queued
- Mark extracting/integrity_check items as completed (already downloaded)
- Handle paused and reconnect_wait items
- Cover all transient package statuses

Updated update tests for beta repo name.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Sucukdeluxe
2026-03-08 19:38:22 +01:00
co-authored by Claude Opus 4.6
parent 25b7104580
commit f25e61573d
2 changed files with 39 additions and 8 deletions
+6 -6
View File
@@ -46,7 +46,7 @@ afterEach(() => {
describe("update", () => {
it("normalizes update repo input", () => {
expect(normalizeUpdateRepo("")).toBe("Administrator/real-debrid-downloader");
expect(normalizeUpdateRepo("")).toBe("Administrator/beta-real-debrid-downloader");
expect(normalizeUpdateRepo("owner/repo")).toBe("owner/repo");
expect(normalizeUpdateRepo("https://codeberg.org/owner/repo")).toBe("owner/repo");
expect(normalizeUpdateRepo("https://www.codeberg.org/owner/repo")).toBe("owner/repo");
@@ -518,14 +518,14 @@ describe("normalizeUpdateRepo extended", () => {
});
it("returns default for malformed inputs", () => {
expect(normalizeUpdateRepo("just-one-part")).toBe("Administrator/real-debrid-downloader");
expect(normalizeUpdateRepo(" ")).toBe("Administrator/real-debrid-downloader");
expect(normalizeUpdateRepo("just-one-part")).toBe("Administrator/beta-real-debrid-downloader");
expect(normalizeUpdateRepo(" ")).toBe("Administrator/beta-real-debrid-downloader");
});
it("rejects traversal-like owner or repo segments", () => {
expect(normalizeUpdateRepo("../owner/repo")).toBe("Administrator/real-debrid-downloader");
expect(normalizeUpdateRepo("owner/../repo")).toBe("Administrator/real-debrid-downloader");
expect(normalizeUpdateRepo("https://codeberg.org/owner/../../repo")).toBe("Administrator/real-debrid-downloader");
expect(normalizeUpdateRepo("../owner/repo")).toBe("Administrator/beta-real-debrid-downloader");
expect(normalizeUpdateRepo("owner/../repo")).toBe("Administrator/beta-real-debrid-downloader");
expect(normalizeUpdateRepo("https://codeberg.org/owner/../../repo")).toBe("Administrator/beta-real-debrid-downloader");
});
it("handles www prefix", () => {