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

Function cbm_remove_indexes

src/cli/cli.c:6400–6429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6398}
6399
6400int cbm_remove_indexes(const char *home_dir) {
6401 const char *cache_dir = get_cache_dir(home_dir);
6402 if (!cache_dir) {
6403 return 0;
6404 }
6405
6406 cbm_dir_t *d = cbm_opendir(cache_dir);
6407 if (!d) {
6408 return 0;
6409 }
6410
6411 int count = 0;
6412 cbm_dirent_t *ent;
6413 while ((ent = cbm_readdir(d)) != NULL) {
6414 size_t len = strlen(ent->name);
6415 if (len > DB_EXT_LEN && strcmp(ent->name + len - DB_EXT_LEN, ".db") == 0) {
6416 char path[CLI_BUF_1K];
6417 snprintf(path, sizeof(path), "%s/%s", cache_dir, ent->name);
6418 /* Also remove .db.tmp if present */
6419 char tmp_path[CLI_FIELD_1040];
6420 snprintf(tmp_path, sizeof(tmp_path), "%s.tmp", path);
6421 cbm_unlink(tmp_path);
6422 if (cbm_unlink(path) == 0) {
6423 count++;
6424 }
6425 }
6426 }
6427 cbm_closedir(d);
6428 return count;
6429}
6430
6431/* ── Config store (persistent key-value in _config.db) ─────────── */
6432

Callers 4

cli_install_activateFunction · 0.85
cli_uninstall_activateFunction · 0.85

Calls 5

get_cache_dirFunction · 0.85
cbm_opendirFunction · 0.85
cbm_readdirFunction · 0.85
cbm_unlinkFunction · 0.85
cbm_closedirFunction · 0.85

Tested by

no test coverage detected