refactor: use canonical implementations and types directly
Remove forwarding wrappers and shadow aliases, migrate callers and verification scripts to their owners, and share one exhaustive semantic resource-bound projection.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import type { BigIntStats } from "node:fs";
|
||||
import { readdir, readlink, realpath } from "node:fs/promises";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
|
||||
@@ -18,7 +19,6 @@ import {
|
||||
bigLstat,
|
||||
} from "./ReferenceSourceReaderValidate.js";
|
||||
import {
|
||||
type BigStats,
|
||||
type PendingDirectory,
|
||||
type ReferenceSourceEntry,
|
||||
type ReferenceSourceResult,
|
||||
@@ -119,7 +119,7 @@ const readDirectoryNames = async (
|
||||
const readMetadata = async (
|
||||
path: string,
|
||||
): Promise<
|
||||
| { readonly ok: true; readonly value: BigStats }
|
||||
| { readonly ok: true; readonly value: BigIntStats }
|
||||
| { readonly ok: false; readonly message: string }
|
||||
> => {
|
||||
try {
|
||||
@@ -193,7 +193,7 @@ const processFileEntry = async (
|
||||
state: TraversalState,
|
||||
absolute: string,
|
||||
path: string,
|
||||
metadata: BigStats,
|
||||
metadata: BigIntStats,
|
||||
): Promise<void> => {
|
||||
const result = await readStableFile({
|
||||
root: state.root,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { BigIntStats } from "node:fs";
|
||||
import { constants } from "node:fs";
|
||||
import { open, type FileHandle } from "node:fs/promises";
|
||||
import { dirname } from "node:path";
|
||||
@@ -13,7 +14,6 @@ import {
|
||||
validateDirectory,
|
||||
} from "./ReferenceSourceReaderValidate.js";
|
||||
import {
|
||||
type BigStats,
|
||||
type ReferenceSourceEntry,
|
||||
type StableFileRequest,
|
||||
} from "./ReferenceSourceReaderTypes.js";
|
||||
@@ -23,7 +23,7 @@ const READ_CHUNK_BYTES = 64 * 1024;
|
||||
type PreparedFileRead =
|
||||
| {
|
||||
readonly status: "ready";
|
||||
readonly before: BigStats;
|
||||
readonly before: BigIntStats;
|
||||
}
|
||||
| { readonly status: "failed"; readonly entry: ReferenceSourceEntry };
|
||||
|
||||
@@ -33,12 +33,12 @@ type FileContentsRead =
|
||||
|
||||
type FinalizeFileReadRequest = {
|
||||
readonly root: string;
|
||||
readonly rootIdentity: BigStats;
|
||||
readonly rootIdentity: BigIntStats;
|
||||
readonly absolute: string;
|
||||
readonly path: string;
|
||||
readonly handle: FileHandle;
|
||||
readonly before: BigStats;
|
||||
readonly parentBefore: { readonly ok: true; readonly stats: BigStats };
|
||||
readonly before: BigIntStats;
|
||||
readonly parentBefore: { readonly ok: true; readonly stats: BigIntStats };
|
||||
readonly chunks: Buffer[];
|
||||
readonly total: number;
|
||||
readonly signal?: AbortSignal;
|
||||
|
||||
@@ -57,15 +57,13 @@ export interface ReferenceSourceReaderError {
|
||||
readonly message: string;
|
||||
}
|
||||
|
||||
export type BigStats = BigIntStats;
|
||||
|
||||
export type PendingDirectory = {
|
||||
readonly path: string;
|
||||
};
|
||||
|
||||
export type TraversalState = {
|
||||
readonly root: string;
|
||||
readonly rootIdentity: BigStats;
|
||||
readonly rootIdentity: BigIntStats;
|
||||
readonly signal?: AbortSignal;
|
||||
readonly shouldExclude?: (path: string) => boolean;
|
||||
readonly entries: ReferenceSourceEntry[];
|
||||
@@ -75,10 +73,10 @@ export type TraversalState = {
|
||||
|
||||
export type StableFileRequest = {
|
||||
readonly root: string;
|
||||
readonly rootIdentity: BigStats;
|
||||
readonly rootIdentity: BigIntStats;
|
||||
readonly absolute: string;
|
||||
readonly path: string;
|
||||
readonly expected: BigStats;
|
||||
readonly expected: BigIntStats;
|
||||
readonly signal?: AbortSignal;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { BigIntStats } from "node:fs";
|
||||
import { constants } from "node:fs";
|
||||
import { lstat, realpath } from "node:fs/promises";
|
||||
|
||||
@@ -9,15 +10,14 @@ import {
|
||||
} from "./ReferenceSourceReaderErrors.js";
|
||||
import { isPathWithinRoot } from "../domain/localPath.js";
|
||||
import {
|
||||
type BigStats,
|
||||
type ReferenceSourceFailureCode,
|
||||
type ReferenceSourceResult,
|
||||
} from "./ReferenceSourceReaderTypes.js";
|
||||
|
||||
export const bigLstat = (path: string): Promise<BigStats> =>
|
||||
export const bigLstat = (path: string): Promise<BigIntStats> =>
|
||||
lstat(path, { bigint: true });
|
||||
|
||||
export const sameFile = (left: BigStats, right: BigStats): boolean =>
|
||||
export const sameFile = (left: BigIntStats, right: BigIntStats): boolean =>
|
||||
left.dev === right.dev &&
|
||||
left.ino === right.ino &&
|
||||
left.size === right.size &&
|
||||
@@ -32,11 +32,11 @@ export const noFollowOpenSupported = (): boolean =>
|
||||
|
||||
export const validateDirectory = async (
|
||||
root: string,
|
||||
rootIdentity: BigStats,
|
||||
rootIdentity: BigIntStats,
|
||||
path: string,
|
||||
signal?: AbortSignal,
|
||||
): Promise<
|
||||
| { readonly ok: true; readonly stats: BigStats }
|
||||
| { readonly ok: true; readonly stats: BigIntStats }
|
||||
| {
|
||||
readonly ok: false;
|
||||
readonly code: ReferenceSourceFailureCode;
|
||||
@@ -94,7 +94,7 @@ export const prepareRoot = async (
|
||||
): Promise<
|
||||
ReferenceSourceResult<{
|
||||
readonly canonicalRoot: string;
|
||||
readonly rootIdentity: BigStats;
|
||||
readonly rootIdentity: BigIntStats;
|
||||
}>
|
||||
> => {
|
||||
if (isAborted(signal)) return err(cancelled());
|
||||
|
||||
Reference in New Issue
Block a user