MCPcopy Create free account
hub / github.com/Noumena-Network/code / getFileIdentity

Function getFileIdentity

src/utils/markdownConfigLoader.ts:202–215  ·  view source on GitHub ↗

* Gets a unique identifier for a file based on its device ID and inode. * This allows detection of duplicate files accessed through different paths * (e.g., via symlinks). Returns null if the file doesn't exist or can't be stat'd. * * Note: On Windows, dev and ino may not be reliable for all fil

(filePath: string)

Source from the content-addressed store, hash-verified

200 * @returns A string identifier "device:inode" or null if file can't be identified
201 */
202async function getFileIdentity(filePath: string): Promise<string | null> {
203 try {
204 const stats = await lstat(filePath, { bigint: true })
205 // Some filesystems (NFS, FUSE, network mounts) report dev=0 and ino=0
206 // for all files, which would cause every file to look like a duplicate.
207 // Return null to skip deduplication for these unreliable identities.
208 if (stats.dev === 0n && stats.ino === 0n) {
209 return null
210 }
211 return `${stats.dev}:${stats.ino}`
212 } catch {
213 return null
214 }
215}
216
217/**
218 * Compute the stop boundary for getProjectDirsUpToHome's upward walk.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected