mirror of
https://github.com/morluto/rea.git
synced 2026-12-03 13:41:17 -05:00
9f5f9c1289
* fix(desktop): retain capture identity and cleanup ownership * fix(desktop): validate destinations and finish inputs before export * fix(desktop): preserve package ownership and apt trust boundaries * fix(sqlite): preserve observed facts and distinguish special real values * fix(desktop): bind computer files to data-object metadata * test(desktop): count the tagged negative-zero cell spelling SQLite view cells encode negative zero as a real object so it stays distinct from the text "-0". The byte budget follows that spelling. * fix(desktop): keep unresolved discovered state directories Canonicalizing an unreadable path or dangling symlink aborted capture before the inventory could record that the path was unknown. Those discovered directories now keep their absolute spelling in the scope. * test(desktop): keep the capture scope suite within its line limit The unresolved state-directory case lives beside the suite so the existing callback stays within the lint limit. * fix(desktop): retain cancellation through capture input cleanup * fix(desktop): avoid reserved Pydantic settings properties --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import { lstat, realpath, stat } from "node:fs/promises";
|
|
import { basename, dirname, join } from "node:path";
|
|
import { absoluteCallerPath } from "./callerPath.js";
|
|
|
|
/** Resolve existing path components without changing the caller's traversal. */
|
|
export const canonicalCallerPath = async (path: string): Promise<string> => {
|
|
const remaining: string[] = [];
|
|
let current = absoluteCallerPath(path);
|
|
for (;;) {
|
|
try {
|
|
const found = await stat(current);
|
|
if (remaining.length > 0 && !found.isDirectory())
|
|
throw Object.assign(
|
|
new Error(`Path parent is not a directory: ${current}`),
|
|
{ code: "ENOTDIR" },
|
|
);
|
|
return join(await realpath(current), ...remaining);
|
|
} catch (cause: unknown) {
|
|
if ((cause as NodeJS.ErrnoException).code !== "ENOENT") throw cause;
|
|
// A dangling symlink is not an absent destination: its target cannot be
|
|
// established. A missing component followed by .. is likewise unknown.
|
|
const existing = await lstat(current).then(
|
|
() => true,
|
|
(error: unknown) => {
|
|
if ((error as NodeJS.ErrnoException).code === "ENOENT") return false;
|
|
throw error;
|
|
},
|
|
);
|
|
if (
|
|
existing ||
|
|
basename(current) === ".." ||
|
|
dirname(current) === current
|
|
)
|
|
throw cause;
|
|
remaining.unshift(basename(current));
|
|
current = dirname(current);
|
|
}
|
|
}
|
|
};
|