Release v1.4.33 with DLC import and stats hotfixes
Build and Release / build (push) Has been cancelled
Build and Release / build (push) Has been cancelled
This commit is contained in:
@@ -78,4 +78,43 @@ describe("container", () => {
|
||||
// Should have tried both!
|
||||
expect(fetchSpy).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("falls back to dcrypt when local decryption throws invalid padding", async () => {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "rd-dlc-"));
|
||||
tempDirs.push(dir);
|
||||
const filePath = path.join(dir, "invalid-local.dlc");
|
||||
fs.writeFileSync(filePath, "X".repeat(120));
|
||||
|
||||
const fetchSpy = vi.fn(async (url: string | URL | Request) => {
|
||||
const urlStr = String(url);
|
||||
if (urlStr.includes("service.jdownloader.org")) {
|
||||
return new Response(`<rc>${Buffer.alloc(16).toString("base64")}</rc>`, { status: 200 });
|
||||
}
|
||||
return new Response("http://example.com/fallback1", { status: 200 });
|
||||
});
|
||||
globalThis.fetch = fetchSpy as unknown as typeof fetch;
|
||||
|
||||
const result = await importDlcContainers([filePath]);
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0].links).toEqual(["http://example.com/fallback1"]);
|
||||
expect(fetchSpy).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("throws clear error when all dlc imports fail", async () => {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "rd-dlc-"));
|
||||
tempDirs.push(dir);
|
||||
const filePath = path.join(dir, "broken.dlc");
|
||||
fs.writeFileSync(filePath, Buffer.from("not a valid dlc payload at all"));
|
||||
|
||||
const fetchSpy = vi.fn(async (url: string | URL | Request) => {
|
||||
const urlStr = String(url);
|
||||
if (urlStr.includes("service.jdownloader.org")) {
|
||||
return new Response("", { status: 404 });
|
||||
}
|
||||
return new Response("upstream failure", { status: 500 });
|
||||
});
|
||||
globalThis.fetch = fetchSpy as unknown as typeof fetch;
|
||||
|
||||
await expect(importDlcContainers([filePath])).rejects.toThrow(/DLC konnte nicht importiert werden/i);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2399,6 +2399,103 @@ describe("download manager", () => {
|
||||
expect(summary).toBeNull();
|
||||
});
|
||||
|
||||
it("shows zero total when queue is empty despite stale persisted bytes", () => {
|
||||
const root = fs.mkdtempSync(path.join(os.tmpdir(), "rd-dm-"));
|
||||
tempDirs.push(root);
|
||||
|
||||
const session = emptySession();
|
||||
session.totalDownloadedBytes = 19.99 * 1024 * 1024 * 1024;
|
||||
session.runStartedAt = Date.now() - 5 * 60 * 1000;
|
||||
|
||||
const manager = new DownloadManager(
|
||||
{
|
||||
...defaultSettings(),
|
||||
token: "rd-token",
|
||||
outputDir: path.join(root, "downloads"),
|
||||
extractDir: path.join(root, "extract"),
|
||||
autoExtract: false
|
||||
},
|
||||
session,
|
||||
createStoragePaths(path.join(root, "state"))
|
||||
);
|
||||
|
||||
const snapshot = manager.getSnapshot();
|
||||
expect(snapshot.stats.totalPackages).toBe(0);
|
||||
expect(snapshot.stats.totalFiles).toBe(0);
|
||||
expect(snapshot.stats.totalDownloaded).toBe(0);
|
||||
expect(snapshot.session.totalDownloadedBytes).toBe(0);
|
||||
expect(snapshot.session.runStartedAt).toBe(0);
|
||||
});
|
||||
|
||||
it("clearAll resets total bytes and stats", () => {
|
||||
const root = fs.mkdtempSync(path.join(os.tmpdir(), "rd-dm-"));
|
||||
tempDirs.push(root);
|
||||
|
||||
const session = emptySession();
|
||||
const packageId = "pkg-clear";
|
||||
const itemId = "item-clear";
|
||||
const now = Date.now() - 1000;
|
||||
const outputDir = path.join(root, "downloads", "pkg-clear");
|
||||
const extractDir = path.join(root, "extract", "pkg-clear");
|
||||
const targetPath = path.join(outputDir, "episode.mkv");
|
||||
|
||||
session.packageOrder = [packageId];
|
||||
session.packages[packageId] = {
|
||||
id: packageId,
|
||||
name: "pkg-clear",
|
||||
outputDir,
|
||||
extractDir,
|
||||
status: "completed",
|
||||
itemIds: [itemId],
|
||||
cancelled: false,
|
||||
enabled: true,
|
||||
createdAt: now,
|
||||
updatedAt: now
|
||||
};
|
||||
session.items[itemId] = {
|
||||
id: itemId,
|
||||
packageId,
|
||||
url: "https://dummy/item-clear",
|
||||
provider: "realdebrid",
|
||||
status: "completed",
|
||||
retries: 0,
|
||||
speedBps: 0,
|
||||
downloadedBytes: 1024,
|
||||
totalBytes: 1024,
|
||||
progressPercent: 100,
|
||||
fileName: "episode.mkv",
|
||||
targetPath,
|
||||
resumable: true,
|
||||
attempts: 1,
|
||||
lastError: "",
|
||||
fullStatus: "Fertig (1 KB)",
|
||||
createdAt: now,
|
||||
updatedAt: now
|
||||
};
|
||||
session.totalDownloadedBytes = 1024;
|
||||
session.runStartedAt = now;
|
||||
|
||||
const manager = new DownloadManager(
|
||||
{
|
||||
...defaultSettings(),
|
||||
token: "rd-token",
|
||||
outputDir: path.join(root, "downloads"),
|
||||
extractDir: path.join(root, "extract"),
|
||||
autoExtract: false
|
||||
},
|
||||
session,
|
||||
createStoragePaths(path.join(root, "state"))
|
||||
);
|
||||
|
||||
manager.clearAll();
|
||||
const snapshot = manager.getSnapshot();
|
||||
expect(snapshot.stats.totalPackages).toBe(0);
|
||||
expect(snapshot.stats.totalFiles).toBe(0);
|
||||
expect(snapshot.stats.totalDownloaded).toBe(0);
|
||||
expect(snapshot.session.totalDownloadedBytes).toBe(0);
|
||||
expect(snapshot.session.runStartedAt).toBe(0);
|
||||
});
|
||||
|
||||
it("does not start a run when queue is empty", async () => {
|
||||
const root = fs.mkdtempSync(path.join(os.tmpdir(), "rd-dm-"));
|
||||
tempDirs.push(root);
|
||||
|
||||
Reference in New Issue
Block a user