Fix auto-recovery for CRC-corrupt archives with correct file sizes

- Trust extractor CRC verdict over file size checks
- Re-queue incomplete downloads instead of just warning

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Sucukdeluxe
2026-03-07 22:26:49 +01:00
co-authored by Claude Opus 4.6
parent 2a429b49c0
commit 556cbd1d85
2 changed files with 38 additions and 10 deletions
+10 -5
View File
@@ -2042,7 +2042,7 @@ describe("download manager", () => {
expect(session.packages[packageId]?.status).toBe("queued");
});
it("does not requeue completed archive parts without local file evidence", () => {
it("requeues completed archive parts on CRC error even when file size matches", () => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), "rd-dm-"));
tempDirs.push(root);
@@ -2121,13 +2121,18 @@ describe("download manager", () => {
"hybrid"
);
expect(changed).toBe(0);
// CRC error from extractor IS evidence of corruption — even when files
// have the right size, content may be corrupt. Must force re-download.
expect(changed).toBe(2);
for (const itemId of itemIds) {
const item = session.items[itemId]!;
expect(item.status).toBe("completed");
expect(item.targetPath).toContain(".rar");
expect(item.downloadedBytes).toBe(archiveSize);
expect(item.status).toBe("queued");
expect(item.targetPath).toBe("");
expect(item.downloadedBytes).toBe(0);
expect(item.fullStatus).toContain("Auto-Recovery");
}
expect(fs.existsSync(path.join(outputDir, archiveNames[0]!))).toBe(false);
expect(fs.existsSync(path.join(outputDir, archiveNames[1]!))).toBe(false);
});
it("does not treat rev files as ready archive parts during disk fallback", async () => {