| 9222 | */ |
| 9223 | int cbm_install_handle_existing_indexes(const char *home, bool reset, bool dry_run); |
| 9224 | static int cbm_install_prepare_existing_indexes(const char *home, bool reset, bool dry_run, |
| 9225 | bool *delete_indexes_out) { |
| 9226 | if (delete_indexes_out) { |
| 9227 | *delete_indexes_out = false; |
| 9228 | } |
| 9229 | int index_count = count_db_indexes(home); |
| 9230 | if (index_count <= 0) { |
| 9231 | return 1; /* nothing to handle, proceed */ |
| 9232 | } |
| 9233 | |
| 9234 | if (!reset) { |
| 9235 | /* Default: preserve. Be honest — keep the indexes, advise re-index. */ |
| 9236 | printf("Found %d existing index(es). Keeping them. After install, " |
| 9237 | "re-index to pick up this version's improvements:\n", |
| 9238 | index_count); |
| 9239 | cbm_list_indexes(home); |
| 9240 | printf("\n"); |
| 9241 | return 1; /* proceed without deleting */ |
| 9242 | } |
| 9243 | |
| 9244 | /* Opt-in reset (--reset-indexes): the original prompt-and-delete path. */ |
| 9245 | printf("Found %d existing index(es):\n", index_count); |
| 9246 | cbm_list_indexes(home); |
| 9247 | printf("\n"); |
| 9248 | if (!prompt_yn("Delete these indexes and continue with install?")) { |
| 9249 | printf("Install cancelled.\n"); |
| 9250 | return 0; /* abort */ |
| 9251 | } |
| 9252 | if (!dry_run && delete_indexes_out) { |
| 9253 | *delete_indexes_out = true; |
| 9254 | } |
| 9255 | return 1; /* proceed */ |
| 9256 | } |
| 9257 | |
| 9258 | int cbm_install_handle_existing_indexes(const char *home, bool reset, bool dry_run) { |
| 9259 | bool delete_indexes = false; |
no test coverage detected