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

Function cbm_remove_indexes

src/cli/cli.c:2653–2682  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2651}
2652
2653int cbm_remove_indexes(const char *home_dir) {
2654 const char *cache_dir = get_cache_dir(home_dir);
2655 if (!cache_dir) {
2656 return 0;
2657 }
2658
2659 cbm_dir_t *d = cbm_opendir(cache_dir);
2660 if (!d) {
2661 return 0;
2662 }
2663
2664 int count = 0;
2665 cbm_dirent_t *ent;
2666 while ((ent = cbm_readdir(d)) != NULL) {
2667 size_t len = strlen(ent->name);
2668 if (len > DB_EXT_LEN && strcmp(ent->name + len - DB_EXT_LEN, ".db") == 0) {
2669 char path[CLI_BUF_1K];
2670 snprintf(path, sizeof(path), "%s/%s", cache_dir, ent->name);
2671 /* Also remove .db.tmp if present */
2672 char tmp_path[CLI_FIELD_1040];
2673 snprintf(tmp_path, sizeof(tmp_path), "%s.tmp", path);
2674 cbm_unlink(tmp_path);
2675 if (cbm_unlink(path) == 0) {
2676 count++;
2677 }
2678 }
2679 }
2680 cbm_closedir(d);
2681 return count;
2682}
2683
2684/* ── Config store (persistent key-value in _config.db) ─────────── */
2685

Callers 3

cbm_cmd_uninstallFunction · 0.85
update_clear_indexesFunction · 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