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.
20 lines
668 B
TypeScript
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,
|
|
}),
|
|
});
|