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

Method freshen

src/mcp/tools.ts:1117–1130  ·  view source on GitHub ↗

* Heal a long-lived connection whose `.codegraph/` was removed and recreated * at the same path (a worktree recreated, or `rm -rf .codegraph` + re-init) * before handing it to a tool. Otherwise the daemon keeps serving the * pre-removal snapshot from its now-unlinked file handle until resta

(cg: CodeGraph)

Source from the content-addressed store, hash-verified

1115 * tool call.
1116 */
1117 private freshen(cg: CodeGraph): CodeGraph {
1118 try {
1119 if (cg.reopenIfReplaced()) {
1120 process.stderr.write(
1121 '[CodeGraph MCP] The index was replaced on disk (e.g. a git worktree ' +
1122 'recreated at the same path); reopened the live database in place.\n'
1123 );
1124 }
1125 } catch {
1126 // Best-effort self-heal — a failed reopen must never break the tool call;
1127 // the (still stale) handle keeps serving and the next call retries.
1128 }
1129 return cg;
1130 }
1131
1132 /**
1133 * Close all cached project connections

Callers 1

getCodeGraphMethod · 0.95

Calls 2

reopenIfReplacedMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected