MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_remove_indexes

Function cbm_remove_indexes

src/cli/cli.c:7351–7385  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7349}
7350
7351int cbm_remove_indexes(const char *home_dir) {
7352 const char *cache_dir = get_cache_dir(home_dir);
7353 if (!cache_dir) {
7354 return 0;
7355 }
7356
7357 cbm_dir_t *d = cbm_opendir(cache_dir);
7358 if (!d) {
7359 return 0;
7360 }
7361
7362 int count = 0;
7363 cbm_dirent_t *ent;
7364 while ((ent = cbm_readdir(d)) != NULL) {
7365 if (cbm_is_project_index_db(ent->name)) {
7366 char path[CLI_BUF_1K];
7367 snprintf(path, sizeof(path), "%s/%s", cache_dir, ent->name);
7368 /* Also remove .db.tmp if present */
7369 char tmp_path[CLI_FIELD_1040];
7370 snprintf(tmp_path, sizeof(tmp_path), "%s.tmp", path);
7371 cbm_unlink(tmp_path);
7372 if (cbm_unlink(path) == 0) {
7373 count++;
7374 }
7375 /* Remove the SQLite sidecars (-wal/-shm/-journal) for both the
7376 * live and staged DBs. Idempotent and ENOENT-tolerant, so it runs
7377 * even when the .db unlink failed -- an orphan -wal can outlive
7378 * its .db. Sidecars are not indexes, so count is unchanged. */
7379 cbm_remove_db_sidecars(path);
7380 cbm_remove_db_sidecars(tmp_path);
7381 }
7382 }
7383 cbm_closedir(d);
7384 return count;
7385}
7386
7387/* ── Config store (persistent key-value in _config.db) ─────────── */
7388

Callers 5

cli_install_activateFunction · 0.85
cli_uninstall_activateFunction · 0.85
test_cli.cFile · 0.85

Calls 7

get_cache_dirFunction · 0.85
cbm_opendirFunction · 0.85
cbm_readdirFunction · 0.85
cbm_is_project_index_dbFunction · 0.85
cbm_unlinkFunction · 0.85
cbm_remove_db_sidecarsFunction · 0.85
cbm_closedirFunction · 0.85

Tested by

no test coverage detected