* The index, through one watch on the data directory. * * Non-recursive and on the directory rather than the database file: SQLite * writes land in `codegraph.db-wal`, and a full re-index REPLACES * `codegraph.db` outright (a watch on the file itself would follow the * unlinked inode
()
| 375 | * unlinked inode and never fire again). |
| 376 | */ |
| 377 | private startIndexWatcher(): void { |
| 378 | if (this.indexWatcher) return; |
| 379 | const dir = getCodeGraphDir(this.projectRoot); |
| 380 | try { |
| 381 | const watcher = fs.watch(dir, { persistent: false }, () => this.scheduleProbe()); |
| 382 | watcher.on('error', () => { |
| 383 | // The data directory went away, or the OS dropped the watch. Nothing to |
| 384 | // retry against — a client that reloads gets a fresh one. |
| 385 | this.indexUp = false; |
| 386 | this.indexWatcher = null; |
| 387 | try { |
| 388 | watcher.close(); |
| 389 | } catch { |
| 390 | /* already closed */ |
| 391 | } |
| 392 | }); |
| 393 | this.indexWatcher = watcher; |
| 394 | this.indexUp = true; |
| 395 | } catch { |
| 396 | this.indexUp = false; |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | /** |
| 401 | * Wait for the writing to stop, then look once. |
no test coverage detected