| 9132 | */ |
| 9133 | int cbm_install_handle_existing_indexes(const char *home, bool reset, bool dry_run); |
| 9134 | static int cbm_install_prepare_existing_indexes(const char *home, bool reset, bool dry_run, |
| 9135 | bool *delete_indexes_out) { |
| 9136 | if (delete_indexes_out) { |
| 9137 | *delete_indexes_out = false; |
| 9138 | } |
| 9139 | int index_count = count_db_indexes(home); |
| 9140 | if (index_count <= 0) { |
| 9141 | return 1; /* nothing to handle, proceed */ |
| 9142 | } |
| 9143 | |
| 9144 | if (!reset) { |
| 9145 | /* Default: preserve. Be honest — keep the indexes, advise re-index. */ |
| 9146 | printf("Found %d existing index(es). Keeping them. After install, " |
| 9147 | "re-index to pick up this version's improvements:\n", |
| 9148 | index_count); |
| 9149 | cbm_list_indexes(home); |
| 9150 | printf("\n"); |
| 9151 | return 1; /* proceed without deleting */ |
| 9152 | } |
| 9153 | |
| 9154 | /* Opt-in reset (--reset-indexes): the original prompt-and-delete path. */ |
| 9155 | printf("Found %d existing index(es):\n", index_count); |
| 9156 | cbm_list_indexes(home); |
| 9157 | printf("\n"); |
| 9158 | if (!prompt_yn("Delete these indexes and continue with install?")) { |
| 9159 | printf("Install cancelled.\n"); |
| 9160 | return 0; /* abort */ |
| 9161 | } |
| 9162 | if (!dry_run && delete_indexes_out) { |
| 9163 | *delete_indexes_out = true; |
| 9164 | } |
| 9165 | return 1; /* proceed */ |
| 9166 | } |
| 9167 | |
| 9168 | int cbm_install_handle_existing_indexes(const char *home, bool reset, bool dry_run) { |
| 9169 | bool delete_indexes = false; |
no test coverage detected