( projectRoot: string, storedPath: string, record: FileRecord )
| 200 | * file) have their own handling in the endpoints that actually read. |
| 201 | */ |
| 202 | export function hasDriftedOnDisk( |
| 203 | projectRoot: string, |
| 204 | storedPath: string, |
| 205 | record: FileRecord |
| 206 | ): boolean { |
| 207 | try { |
| 208 | const absolute = resolveProjectFile(projectRoot, storedPath); |
| 209 | const stats = fs.statSync(absolute); |
| 210 | if (stats.size === record.size && Math.floor(stats.mtimeMs) === Math.floor(record.modifiedAt)) { |
| 211 | return false; |
| 212 | } |
| 213 | // A file over the index's size limit is stored as its size stamp (#1910), |
| 214 | // so it is compared as one — without reading it. |
| 215 | const hashed = indexedHashInput(stats.size, () => fs.readFileSync(absolute, 'utf-8')); |
| 216 | return createHash('sha256').update(hashed).digest('hex') !== record.contentHash; |
| 217 | } catch { |
| 218 | return false; |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | /** |
| 223 | * The drift verdict AND the file's length, from one read. |
no test coverage detected