| 6562 | } |
| 6563 | |
| 6564 | int cbm_remove_indexes(const char *home_dir) { |
| 6565 | const char *cache_dir = get_cache_dir(home_dir); |
| 6566 | if (!cache_dir) { |
| 6567 | return 0; |
| 6568 | } |
| 6569 | |
| 6570 | cbm_dir_t *d = cbm_opendir(cache_dir); |
| 6571 | if (!d) { |
| 6572 | return 0; |
| 6573 | } |
| 6574 | |
| 6575 | int count = 0; |
| 6576 | cbm_dirent_t *ent; |
| 6577 | while ((ent = cbm_readdir(d)) != NULL) { |
| 6578 | size_t len = strlen(ent->name); |
| 6579 | if (len > DB_EXT_LEN && strcmp(ent->name + len - DB_EXT_LEN, ".db") == 0) { |
| 6580 | char path[CLI_BUF_1K]; |
| 6581 | snprintf(path, sizeof(path), "%s/%s", cache_dir, ent->name); |
| 6582 | /* Also remove .db.tmp if present */ |
| 6583 | char tmp_path[CLI_FIELD_1040]; |
| 6584 | snprintf(tmp_path, sizeof(tmp_path), "%s.tmp", path); |
| 6585 | cbm_unlink(tmp_path); |
| 6586 | if (cbm_unlink(path) == 0) { |
| 6587 | count++; |
| 6588 | } |
| 6589 | } |
| 6590 | } |
| 6591 | cbm_closedir(d); |
| 6592 | return count; |
| 6593 | } |
| 6594 | |
| 6595 | /* ── Config store (persistent key-value in _config.db) ─────────── */ |
| 6596 |
no test coverage detected