mirror of
https://github.com/morluto/rea.git
synced 2026-12-02 11:33:10 +00:00
24 lines
709 B
TypeScript
24 lines
709 B
TypeScript
import type { Stats } from "node:fs";
|
|
import { lstat } from "node:fs/promises";
|
|
import { sameRegularFileState } from "../filesystem/RegularFile.js";
|
|
import { isEnoentError } from "./ClientConfigPath.js";
|
|
|
|
/** Check the selected entry at its name without following a replacement symlink. */
|
|
export const publicationPathMatchesSelection = async (
|
|
path: string,
|
|
selected: Stats | undefined,
|
|
): Promise<boolean> => {
|
|
let named: Stats;
|
|
try {
|
|
named = await lstat(path);
|
|
} catch (cause: unknown) {
|
|
if (isEnoentError(cause)) return selected === undefined;
|
|
throw cause;
|
|
}
|
|
return (
|
|
selected !== undefined &&
|
|
!named.isSymbolicLink() &&
|
|
sameRegularFileState(selected, named)
|
|
);
|
|
};
|