* 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)
| 157 | * @returns A string identifier "device:inode" or null if file can't be identified |
| 158 | */ |
| 159 | async function getFileIdentity(filePath: string): Promise<string | null> { |
| 160 | try { |
| 161 | const stats = await lstat(filePath, { bigint: true }) |
| 162 | // Some filesystems (NFS, FUSE, network mounts) report dev=0 and ino=0 |
| 163 | // for all files, which would cause every file to look like a duplicate. |
| 164 | // Return null to skip deduplication for these unreliable identities. |
| 165 | if (stats.dev === 0n && stats.ino === 0n) { |
| 166 | return null |
| 167 | } |
| 168 | return `${stats.dev}:${stats.ino}` |
| 169 | } catch { |
| 170 | return null |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * Compute the stop boundary for getProjectDirsUpToHome's upward walk. |
no outgoing calls
no test coverage detected