mirror of
https://github.com/morluto/rea.git
synced 2026-11-17 04:04:25 +00:00
fix(reference)!: preserve symlink races and root failure facts
Classify replacement EINVAL at the readlink syscall so the reader and importer retain sibling observations. Give an admitted root's enumeration failure its own typed field, use it for unresolved symlink coverage, and project it as a graph limitation instead of an invalid dot-path child entry. Keep admission, cancellation and cleanup failures distinct. Closes #5135 Closes #5136 BREAKING CHANGE: Partial reference-source reader results report failed root enumeration in rootFailure instead of a failed directory child at path ".". Historical source graphs preserve the root failure as a top-level limitation.
This commit is contained in:
1 parent
c85b44e1b1
commit
6296fdf560
8 files changed
+312
-42
No files matched your search
@@ -9,6 +9,7 @@ import { traverseDirectory } from "./ReferenceSourceReaderEntries.js";
|
||||
import type {
|
||||
ReferenceSourceReaderOptions,
|
||||
ReferenceSourceEntry,
|
||||
ReferenceSourceRootFailure,
|
||||
ReferenceSourceRead,
|
||||
ReferenceSourceResult,
|
||||
TraversalState,
|
||||
@@ -78,12 +79,16 @@ const readSource = async (
|
||||
state.entries,
|
||||
state.exclusions,
|
||||
state.signal,
|
||||
state.rootFailure,
|
||||
);
|
||||
state.entries.sort((left, right) =>
|
||||
compareUnicodeCodePoints(left.path, right.path),
|
||||
);
|
||||
const read: ReferenceSourceRead = {
|
||||
root: canonicalRoot,
|
||||
...(state.rootFailure === undefined
|
||||
? {}
|
||||
: { rootFailure: state.rootFailure }),
|
||||
entries: state.entries,
|
||||
bytesRead: state.bytesRead,
|
||||
limitations: [PATH_RACE_LIMITATION],
|
||||
@@ -101,6 +106,7 @@ export const reconcileUnobservedSymlinkTargets = (
|
||||
entries: ReferenceSourceEntry[],
|
||||
exclusions: TraversalState["exclusions"] = [],
|
||||
signal?: AbortSignal,
|
||||
rootFailure?: ReferenceSourceRootFailure,
|
||||
): void => {
|
||||
const failedDirectories = new Map(
|
||||
entries.flatMap((entry) =>
|
||||
@@ -111,7 +117,11 @@ export const reconcileUnobservedSymlinkTargets = (
|
||||
: [],
|
||||
),
|
||||
);
|
||||
if (failedDirectories.size === 0 || isAborted(signal)) return;
|
||||
if (
|
||||
(failedDirectories.size === 0 && rootFailure === undefined) ||
|
||||
isAborted(signal)
|
||||
)
|
||||
return;
|
||||
const directoryEntries = entries.filter(
|
||||
(entry) => entry.kind === "directory",
|
||||
);
|
||||
@@ -140,6 +150,7 @@ export const reconcileUnobservedSymlinkTargets = (
|
||||
failedDirectories,
|
||||
excludedPaths,
|
||||
signal,
|
||||
rootFailure,
|
||||
);
|
||||
if (ancestor === undefined) continue;
|
||||
entries[index] = {
|
||||
@@ -161,7 +172,8 @@ const nearestFailedAncestor = (
|
||||
>,
|
||||
excludedPaths: ReturnType<typeof createReferenceSourcePathLookup>,
|
||||
signal: AbortSignal | undefined,
|
||||
): Extract<ReferenceSourceEntry, { status: "failed" }> | undefined => {
|
||||
rootFailure: ReferenceSourceRootFailure | undefined,
|
||||
): (ReferenceSourceRootFailure & { readonly path: string }) | undefined => {
|
||||
for (
|
||||
let candidate = posix.dirname(target);
|
||||
candidate !== "." && candidate !== "/";
|
||||
@@ -175,10 +187,7 @@ const nearestFailedAncestor = (
|
||||
}
|
||||
if (isAborted(signal)) return undefined;
|
||||
if (excludedPaths.resolve(".") !== undefined) return undefined;
|
||||
const observedRoot = directoryPaths.resolve(".");
|
||||
return observedRoot === undefined
|
||||
? undefined
|
||||
: failedDirectories.get(observedRoot);
|
||||
return rootFailure === undefined ? undefined : { path: ".", ...rootFailure };
|
||||
};
|
||||
|
||||
const traverse = async (
|
||||
|
||||
Reference in new issue
Block a user