fix(hopper): keep the OS error when the FAT64 source cannot be reopened

resolveHopperMachOImage built its BinaryTargetError without the open
failure as its cause, so a target that became unreadable after admission
still projected as `target_unavailable` instead of `access_denied`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kaoru0822
2026-10-09 04:04:42 +00:00
co-authored by Claude Opus 5.5
parent d0ff57a45c
commit 9f5dc52be8
2 changed files with 47 additions and 2 deletions
+10 -2
View File
@@ -35,15 +35,23 @@ export const resolveHopperMachOImage = async (
): Promise<
Result<HopperMachOImage, BinaryTargetError | AnalysisCancelledError>
> => {
const invalid = (reason: string) =>
err(new BinaryTargetError(target.path, reason));
const invalid = (reason: string, cause?: unknown) =>
err(
new BinaryTargetError(
target.path,
reason,
cause === undefined ? undefined : { cause },
),
);
if (signal?.aborted) return err(new AnalysisCancelledError("open_binary"));
let file: FileHandle;
try {
file = await open(target.path, "r");
} catch (cause: unknown) {
// Keep the OS error so a read-permission denial reports access_denied.
return invalid(
`Cannot read FAT64 source for Hopper image preparation: ${cause instanceof Error ? cause.message : String(cause)}`,
cause,
);
}
try {