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

Method isIndexedFileStateCurrent

src/index.ts:2089–2107  ·  view source on GitHub ↗

* Whether an OS watcher event points at a file whose index metadata is still * current. Used on Windows to discard NTFS last-access notifications, which * libuv reports through fs.watch as ordinary change events (#1451).

(filePath: string)

Source from the content-addressed store, hash-verified

2087 * libuv reports through fs.watch as ordinary change events (#1451).
2088 */
2089 private isIndexedFileStateCurrent(filePath: string): boolean {
2090 const tracked = this.queries.getFileByPath(filePath);
2091 if (!tracked) return false;
2092
2093 try {
2094 const stat = fs.statSync(path.join(this.projectRoot, filePath));
2095 return (
2096 stat.isFile() &&
2097 Number.isFinite(stat.mtimeMs) &&
2098 Number.isFinite(tracked.modifiedAt) &&
2099 stat.size === tracked.size &&
2100 Math.floor(stat.mtimeMs) === Math.floor(tracked.modifiedAt)
2101 );
2102 } catch {
2103 // Missing/inaccessible files must still reach sync so removals and
2104 // transient filesystem failures are reconciled rather than hidden.
2105 return false;
2106 }
2107 }
2108
2109 /**
2110 * Start watching for file changes and auto-syncing.

Callers 1

watchMethod · 0.95

Calls 2

getFileByPathMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected