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

Method catchUpSync

src/mcp/engine.ts:503–525  ·  view source on GitHub ↗

* Reconcile the index with the current filesystem once, right after open — * catches edits, adds, deletes, and `git pull`/`checkout` changes made while * no watcher was running. Runs in the background, but the returned promise * is pushed into the ToolHandler as a one-shot gate so the *firs

(afterReopen = false)

Source from the content-addressed store, hash-verified

501 * is populated by the watcher, not by catch-up).
502 */
503 private catchUpSync(afterReopen = false): void {
504 const cg = this.cg;
505 if (!cg || this.opts.readOnly) return;
506 // The lease's gate is the startup reconcile and stays settled once caught
507 // up; a database reopened after a rebuild (#1902) needs a sync of its own.
508 if (this.defaultLease && !afterReopen) {
509 this.toolHandler.setCatchUpGate(this.defaultLease.ready());
510 return;
511 }
512 const p = cg
513 .sync()
514 .then((result) => {
515 const changed = result.filesAdded + result.filesModified + result.filesRemoved;
516 if (changed > 0) {
517 process.stderr.write(`[CodeGraph MCP] Caught up ${changed} file(s) changed since last run\n`);
518 }
519 })
520 .catch((err) => {
521 const msg = err instanceof Error ? err.message : String(err);
522 process.stderr.write(`[CodeGraph MCP] Catch-up sync failed: ${msg}\n`);
523 });
524 this.toolHandler.setCatchUpGate(p);
525 }
526}
527
528/**

Callers 3

constructorMethod · 0.95
retryInitializeSyncMethod · 0.95
doInitializeMethod · 0.95

Calls 4

setCatchUpGateMethod · 0.80
readyMethod · 0.65
writeMethod · 0.65
syncMethod · 0.45

Tested by

no test coverage detected