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

Method isIndexedFileStateCurrent

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

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