Fix archive underflow and extraction readiness

This commit is contained in:
Sucukdeluxe
2026-03-07 21:08:43 +01:00
parent 0f2e8d5567
commit 16bfbfc106
4 changed files with 209 additions and 5 deletions
+21
View File
@@ -11,6 +11,7 @@ import {
detectArchiveSignature,
classifyExtractionError,
findArchiveCandidates,
resolveExtractorBackendMode,
} from "../src/main/extractor";
const tempDirs: string[] = [];
@@ -988,6 +989,10 @@ describe("extractor", () => {
expect(classifyExtractionError("WinRAR/UnRAR nicht gefunden")).toBe("no_extractor");
});
it("prioritizes checksum errors over embedded wrong-password wording", () => {
expect(classifyExtractionError("Checksum error in the encrypted file. Corrupt file or wrong password.")).toBe("crc_error");
});
it("returns unknown for unrecognized errors", () => {
expect(classifyExtractionError("something weird happened")).toBe("unknown");
});
@@ -1086,4 +1091,20 @@ describe("extractor", () => {
expect(result.failed).toBe(0);
});
});
describe("backend selection", () => {
it("defaults to auto in production when no backend override is set", () => {
expect(resolveExtractorBackendMode(undefined, false)).toBe("auto");
});
it("defaults to legacy in vitest when no backend override is set", () => {
expect(resolveExtractorBackendMode(undefined, true)).toBe("legacy");
});
it("respects explicit backend overrides", () => {
expect(resolveExtractorBackendMode("legacy", false)).toBe("legacy");
expect(resolveExtractorBackendMode("jvm", false)).toBe("jvm");
expect(resolveExtractorBackendMode("auto", false)).toBe("auto");
});
});
});