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

Function hasDriftedOnDisk

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

Source from the content-addressed store, hash-verified

200 * file) have their own handling in the endpoints that actually read.
201 */
202export 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.

Callers 7

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

Calls 2

resolveProjectFileFunction · 0.90
indexedHashInputFunction · 0.90

Tested by

no test coverage detected