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

Function count_db_indexes

src/cli/cli.c:3567–3586  ·  view source on GitHub ↗

Count .db files in the cache directory. */

Source from the content-addressed store, hash-verified

3565
3566/* Count .db files in the cache directory. */
3567static int count_db_indexes(const char *home) {
3568 const char *cache_dir = get_cache_dir(home);
3569 if (!cache_dir) {
3570 return 0;
3571 }
3572 cbm_dir_t *d = cbm_opendir(cache_dir);
3573 if (!d) {
3574 return 0;
3575 }
3576 int count = 0;
3577 cbm_dirent_t *ent;
3578 while ((ent = cbm_readdir(d)) != NULL) {
3579 size_t len = strlen(ent->name);
3580 if (len > DB_EXT_LEN && strcmp(ent->name + len - DB_EXT_LEN, ".db") == 0) {
3581 count++;
3582 }
3583 }
3584 cbm_closedir(d);
3585 return count;
3586}
3587
3588/* Handle pre-existing indexes during (re)install (#607).
3589 *

Callers 3

cbm_cmd_uninstallFunction · 0.85
update_clear_indexesFunction · 0.85

Calls 4

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

Tested by

no test coverage detected