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

Function cbm_remove_indexes

src/cli/cli.c:6344–6373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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