MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / hasDriftedOnDisk

Function hasDriftedOnDisk

src/ui-server/api/source.ts:204–222  ·  view source on GitHub ↗
(
  projectRoot: string,
  storedPath: string,
  record: FileRecord
)

Source from the content-addressed store, hash-verified

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

Callers 7

annotateWhenFunction · 0.90
resolveFunction · 0.90
loadFileFunction · 0.90
driftForFunction · 0.90
buildFileFunction · 0.90
mentionsOfFunction · 0.90

Calls 3

resolveProjectFileFunction · 0.90
indexedHashInputFunction · 0.90
updateMethod · 0.80

Tested by

no test coverage detected