perf(artifacts): stream ASAR members without full buffering (#962)
* fix(artifacts): stream ASAR members without full buffering * fix(artifacts): close unopened ASAR member streams * fix(artifacts): preserve unpacked ASAR mismatch digests * fix(artifacts): preserve ASAR read failures * fix(artifacts): retain unpacked ASAR stat failures * fix(artifacts): validate ASAR entry producer identity
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { mkdir, rm, writeFile } from "node:fs/promises";
|
||||
import { lstat, mkdir, rm, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { createPackage } from "@electron/asar";
|
||||
@@ -86,6 +86,24 @@ describe("JavaScript artifact ingestion content identities", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects a same-size ASAR replacement against the inventoried root digest", async () => {
|
||||
const { source, archive } = await fixture();
|
||||
const snapshot = await scanArtifactInventory(archive);
|
||||
const original = await lstat(archive);
|
||||
await writeFile(join(source, "main.js"), "module.exports = 43;\n");
|
||||
await createPackage(source, archive);
|
||||
expect((await lstat(archive)).size).toBe(original.size);
|
||||
|
||||
const reader = new AsarArtifactReader(archive);
|
||||
try {
|
||||
await expect(
|
||||
readJavaScriptArtifactFiles(reader, snapshot),
|
||||
).rejects.toMatchObject({ reason: "integrity" });
|
||||
} finally {
|
||||
await reader.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("preserves typed cancellation when the direct ASAR filesystem stream aborts", async () => {
|
||||
const { archive } = await fixture();
|
||||
const snapshot = await scanArtifactInventory(archive);
|
||||
|
||||
Reference in New Issue
Block a user