Persist collector state and stabilize download controls

Persist collector packages and disclosure state through validated atomic AppData storage with backup recovery and shutdown synchronization. Align download sidebar metrics with the hidden-extracted presentation scope and keep Start available through temporary Real-Debrid cooldowns while preserving hard account blocks.
This commit is contained in:
Sucukdeluxe
2026-08-26 17:24:07 +02:00
parent 5644ba25da
commit bdcf9e3754
20 changed files with 933 additions and 48 deletions
+44
View File
@@ -962,6 +962,50 @@ describe("download start account gate", () => {
expect(getProviderRuntimeSnapshot().realDebrid.accounts.find((entry) => entry.accountId === accountId)?.cooldown ?? null).toBeNull();
});
it("keeps start available after stop when the last enabled Real-Debrid account has a transient cooldown", async () => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), "rd-survivor-cooldown-gate-"));
tempDirs.push(root);
const accountIds = ["rdw_first", "rdw_second", "rdw_third", "rdw_survivor"];
const session = emptySession();
session.running = true;
const manager = new DownloadManager(
{
...defaultSettings(),
realDebridUseWebLogin: true,
realDebridWebAccountIds: accountIds,
realDebridDisabledAccountIds: accountIds.slice(0, 3),
providerOrder: ["realdebrid"]
},
session,
createStoragePaths(path.join(root, "state"))
);
primeRealDebridRuntimeCooldownForTests("rdw_survivor", 60_000, "Temporärer Providerfehler");
await manager.stop();
expect(manager.getSnapshot().session.running).toBe(false);
expect(manager.getSnapshot().canStart).toBe(true);
});
it.each(["invalid", "rate_limit", "quota"] as const)("keeps start blocked for a Real-Debrid %s cooldown", (category) => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), `rd-${category}-cooldown-gate-`));
tempDirs.push(root);
const accountId = `rdw_${category}`;
const manager = new DownloadManager(
{
...defaultSettings(),
realDebridUseWebLogin: true,
realDebridWebAccountIds: [accountId],
providerOrder: ["realdebrid"]
},
emptySession(),
createStoragePaths(path.join(root, "state"))
);
primeRealDebridRuntimeCooldownForTests(accountId, 60_000, "Account nicht nutzbar", category);
expect(manager.getSnapshot().canStart).toBe(false);
});
it("allows start when an active account is available", () => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), "rd-active-account-gate-"));
tempDirs.push(root);