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

Function cbm_remove_indexes

src/cli/cli.c:6338–6367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6336}
6337
6338int cbm_remove_indexes(const char *home_dir) {
6339 const char *cache_dir = get_cache_dir(home_dir);
6340 if (!cache_dir) {
6341 return 0;
6342 }
6343
6344 cbm_dir_t *d = cbm_opendir(cache_dir);
6345 if (!d) {
6346 return 0;
6347 }
6348
6349 int count = 0;
6350 cbm_dirent_t *ent;
6351 while ((ent = cbm_readdir(d)) != NULL) {
6352 size_t len = strlen(ent->name);
6353 if (len > DB_EXT_LEN && strcmp(ent->name + len - DB_EXT_LEN, ".db") == 0) {
6354 char path[CLI_BUF_1K];
6355 snprintf(path, sizeof(path), "%s/%s", cache_dir, ent->name);
6356 /* Also remove .db.tmp if present */
6357 char tmp_path[CLI_FIELD_1040];
6358 snprintf(tmp_path, sizeof(tmp_path), "%s.tmp", path);
6359 cbm_unlink(tmp_path);
6360 if (cbm_unlink(path) == 0) {
6361 count++;
6362 }
6363 }
6364 }
6365 cbm_closedir(d);
6366 return count;
6367}
6368
6369/* ── Config store (persistent key-value in _config.db) ─────────── */
6370

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