fix(electron): keep missing unpacked ASAR entries unavailable

This commit is contained in:
N0zoM1z0
2026-07-16 23:35:48 +09:00
committed by N0zoM1z0
parent aefdf512cd
commit fb6964a74e
5 changed files with 109 additions and 13 deletions
+21 -1
View File
@@ -375,6 +375,9 @@ const emptyScan = (): {
readonly pendingContradictions: PendingIntegrityContradiction[];
} => ({ nodes: new Map(), occurrences: [], pendingContradictions: [] });
const UNAVAILABLE_UNPACKED_LIMITATION =
"ASAR unpacked companion bytes were unavailable; no content hash or child artifact was produced.";
interface PendingIntegrityContradiction {
readonly logicalPath: string;
readonly declaredSha256: string;
@@ -497,7 +500,16 @@ const scanReader = async (
logicalPath,
parent?.occurrence_id ?? null,
);
const digested = await digestEntry(currentReader, entry, logicalPath);
let digested:
| { readonly node: ArtifactNode; readonly mismatched: boolean }
| undefined;
try {
digested = await digestEntry(currentReader, entry, logicalPath);
} catch (cause: unknown) {
if (!isUnavailableUnpackedEntry(cause, entry)) throw cause;
occurrence.hash_status = "unavailable";
occurrence.limitations.push(UNAVAILABLE_UNPACKED_LIMITATION);
}
if (digested !== undefined) {
nodes.set(digested.node.artifact_id, digested.node);
occurrence.artifact_id = digested.node.artifact_id;
@@ -519,6 +531,14 @@ const scanReader = async (
return { nodes, occurrences, pendingContradictions };
};
const isUnavailableUnpackedEntry = (
cause: unknown,
entry: ArtifactEntry,
): boolean =>
entry.unpacked &&
cause instanceof ArtifactReaderFailure &&
cause.reason === "unavailable";
const classifyRoot = async (
path: string,
directory: boolean,