| 6342 | } |
| 6343 | |
| 6344 | int 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 |
no test coverage detected