MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / refresh_file_token_map

Method refresh_file_token_map

src/mcp/server.rs:1173–1181  ·  view source on GitHub ↗

Re-read the file-to-token-count map from the DB and swap it into the cached `file_token_map`. Called after each lazy sync triggered by [`maybe_sync_if_stale`](Self::maybe_sync_if_stale) so the accounting tracks newly indexed / removed files.

(&self)

Source from the content-addressed store, hash-verified

1171 /// [`maybe_sync_if_stale`](Self::maybe_sync_if_stale) so the accounting
1172 /// tracks newly indexed / removed files.
1173 pub async fn refresh_file_token_map(&self) {
1174 // best-effort; leave stale map in place if the DB read fails
1175 let Ok(fresh) = self.cg_snapshot().await.get_file_token_map().await else {
1176 return;
1177 };
1178 if let Ok(mut guard) = self.file_token_map.lock() {
1179 *guard = fresh;
1180 }
1181 }
1182
1183 /// Catch-up sync helper for tests and explicit callers. Bypasses the 30 s
1184 /// cooldown in [`Self::maybe_sync_if_stale`] so changes made while the

Calls 2

get_file_token_mapMethod · 0.80
cg_snapshotMethod · 0.80