Files
rea/src/artifacts/readArtifactFileChunks.ts
T
morluto 542fa84957 fix(artifacts): retain descriptor ownership and read completion facts
Refs #4458, #4483.

Own admitted descriptors through final close, retain exact failed owners, and preserve physical read failures and cancellation reasons. Track stream coverage independently from delivered bytes and share the boundary across archive, Mach-O, hashing, and output readback consumers.
2026-10-17 00:44:02 +08:00

20 lines
668 B
TypeScript

import type { FileHandle } from "node:fs/promises";
import {
readFileHandleChunks,
type FileHandleChunkOptions,
} from "../filesystem/readFileHandleChunks.js";
import { ArtifactReaderFailure } from "./ArtifactReader.js";
/** Produce artifact cancellation facts at the actual descriptor read boundary. */
export const readArtifactFileChunks = (
handle: Pick<FileHandle, "read">,
options: Pick<FileHandleChunkOptions, "start" | "end" | "signal"> = {},
) =>
readFileHandleChunks(handle, {
...options,
cancellationFailure: (reason) =>
new ArtifactReaderFailure("cancelled", "Artifact file read cancelled", {
cause: reason,
}),
});