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

Method freshen

src/mcp/tools.ts:1128–1141  ·  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

1126 * tool call.
1127 */
1128 private freshen(cg: CodeGraph): CodeGraph {
1129 try {
1130 if (cg.reopenIfReplaced()) {
1131 process.stderr.write(
1132 '[CodeGraph MCP] The index was replaced on disk (e.g. a git worktree ' +
1133 'recreated at the same path); reopened the live database in place.\n'
1134 );
1135 }
1136 } catch {
1137 // Best-effort self-heal — a failed reopen must never break the tool call;
1138 // the (still stale) handle keeps serving and the next call retries.
1139 }
1140 return cg;
1141 }
1142
1143 /**
1144 * Close all cached project connections

Callers 1

getCodeGraphMethod · 0.95

Calls 2

reopenIfReplacedMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected