fix: consolidate boundary ownership and cleanup failure paths (#477)

This commit is contained in:
morluto
2026-09-08 10:59:13 +08:00
committed by GitHub
parent c490d85045
commit 2160d4fae5
138 changed files with 2220 additions and 1781 deletions
+17 -13
View File
@@ -86,20 +86,24 @@ export class DirectoryArtifactReader implements ArtifactReader {
entry.adapterKey,
constants.O_RDONLY | constants.O_NOFOLLOW,
);
const observed = await handle.stat();
if (
!observed.isFile() ||
entry.sourceIdentity === undefined ||
observed.dev !== entry.sourceIdentity.device ||
observed.ino !== entry.sourceIdentity.inode
) {
await handle.close();
throw new ArtifactReaderFailure(
"integrity",
`Directory entry changed before open: ${entry.path}`,
);
try {
const observed = await handle.stat();
if (
!observed.isFile() ||
entry.sourceIdentity === undefined ||
observed.dev !== entry.sourceIdentity.device ||
observed.ino !== entry.sourceIdentity.inode
) {
throw new ArtifactReaderFailure(
"integrity",
`Directory entry changed before open: ${entry.path}`,
);
}
return handle.createReadStream({ autoClose: true });
} catch (cause: unknown) {
await handle.close().catch(() => undefined);
throw cause;
}
return handle.createReadStream({ autoClose: true });
}
close(): Promise<void> {