| 2651 | } |
| 2652 | |
| 2653 | int 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 |
no test coverage detected