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

Method isIndexedFileStateCurrent

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

2105 * libuv reports through fs.watch as ordinary change events (#1451).
2106 */
2107 private isIndexedFileStateCurrent(filePath: string): boolean {
2108 const tracked = this.queries.getFileByPath(filePath);
2109 if (!tracked) return false;
2110
2111 try {
2112 const stat = fs.statSync(path.join(this.projectRoot, filePath));
2113 return (
2114 stat.isFile() &&
2115 Number.isFinite(stat.mtimeMs) &&
2116 Number.isFinite(tracked.modifiedAt) &&
2117 stat.size === tracked.size &&
2118 Math.floor(stat.mtimeMs) === Math.floor(tracked.modifiedAt)
2119 );
2120 } catch {
2121 // Missing/inaccessible files must still reach sync so removals and
2122 // transient filesystem failures are reconciled rather than hidden.
2123 return false;
2124 }
2125 }
2126
2127 /**
2128 * 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