From cb13a27bfa1f238c8b9a3c0d88a825f7aceda460 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Sun, 11 Oct 2026 02:49:05 +0800 Subject: [PATCH] perf(artifacts): reuse the admitted ASAR header size Use the header size already validated against the owned archive snapshot instead of asking the ASAR SDK to read and allocate its raw header again. Validation: ASAR freshness, containment, streaming-allocation, and MCP extraction suites passed within the 285-test focused run. check:fast and architecture guards passed. --- src/artifacts/AsarArtifactReader.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/artifacts/AsarArtifactReader.ts b/src/artifacts/AsarArtifactReader.ts index 80e9fec0f..9b33d03ea 100644 --- a/src/artifacts/AsarArtifactReader.ts +++ b/src/artifacts/AsarArtifactReader.ts @@ -19,7 +19,7 @@ import { isAbsolute, join, relative, sep } from "node:path"; import { Readable, Transform } from "node:stream"; import { pipeline } from "node:stream/promises"; -import { getRawHeader, listPackage, statFile, uncache } from "@electron/asar"; +import { listPackage, statFile, uncache } from "@electron/asar"; import { ArtifactReaderFailure, @@ -65,6 +65,7 @@ export class AsarArtifactReader implements ArtifactReader { try { const admitted = await admitAsarHeader(headerHandle); this.#archiveSize = admitted.archiveBytes; + this.#headerSize = admitted.headerBytes; } finally { await headerHandle.close(); } @@ -72,7 +73,6 @@ export class AsarArtifactReader implements ArtifactReader { paths = listPackage(snapshotPath, { isPack: false }).sort((left, right) => left.localeCompare(right, "en"), ); - this.#headerSize = getRawHeader(snapshotPath).headerSize; const archiveMetadata = await lstat(snapshotPath); if (!archiveMetadata.isFile() || archiveMetadata.isSymbolicLink()) throw new ArtifactReaderFailure(