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

Method handleDirEvent

src/sync/watcher.ts:543–561  ·  view source on GitHub ↗

* Linux per-directory event handler. `filename` is relative to `dir`. A new * sub-directory is picked up by extending the watch tree; everything else is * routed through the shared change handler.

(dir: string, filename: string | Buffer | null)

Source from the content-addressed store, hash-verified

541 * routed through the shared change handler.
542 */
543 private handleDirEvent(dir: string, filename: string | Buffer | null): void {
544 if (this.stopped || filename == null) return;
545 const full = path.join(dir, String(filename));
546
547 // A newly-created directory needs its own watch (recursive isn't available
548 // on Linux). statSync is cheap and these events are rare relative to file
549 // edits. If the path vanished (rapid create/delete) the stat throws and we
550 // fall through to the change handler, which no-ops on a non-source path.
551 try {
552 if (fs.statSync(full).isDirectory()) {
553 if (!this.shouldIgnoreDir(full)) this.watchTree(full, /* markExisting */ true);
554 return;
555 }
556 } catch {
557 // deleted/inaccessible — treat as a normal change below
558 }
559
560 this.handleChange(normalizePath(path.relative(this.projectRoot, full)));
561 }
562
563 /**
564 * Shared change handler for both watch strategies. `rel` is a

Callers 1

watchTreeMethod · 0.95

Calls 5

shouldIgnoreDirMethod · 0.95
watchTreeMethod · 0.95
handleChangeMethod · 0.95
normalizePathFunction · 0.90
joinMethod · 0.45

Tested by

no test coverage detected