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

Method isIndexedFileStateCurrent

src/index.ts:2084–2102  ·  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

2082 * libuv reports through fs.watch as ordinary change events (#1451).
2083 */
2084 private isIndexedFileStateCurrent(filePath: string): boolean {
2085 const tracked = this.queries.getFileByPath(filePath);
2086 if (!tracked) return false;
2087
2088 try {
2089 const stat = fs.statSync(path.join(this.projectRoot, filePath));
2090 return (
2091 stat.isFile() &&
2092 Number.isFinite(stat.mtimeMs) &&
2093 Number.isFinite(tracked.modifiedAt) &&
2094 stat.size === tracked.size &&
2095 Math.floor(stat.mtimeMs) === Math.floor(tracked.modifiedAt)
2096 );
2097 } catch {
2098 // Missing/inaccessible files must still reach sync so removals and
2099 // transient filesystem failures are reconciled rather than hidden.
2100 return false;
2101 }
2102 }
2103
2104 /**
2105 * 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