| 9026 | */ |
| 9027 | int cbm_install_handle_existing_indexes(const char *home, bool reset, bool dry_run); |
| 9028 | static int cbm_install_prepare_existing_indexes(const char *home, bool reset, bool dry_run, |
| 9029 | bool *delete_indexes_out) { |
| 9030 | if (delete_indexes_out) { |
| 9031 | *delete_indexes_out = false; |
| 9032 | } |
| 9033 | int index_count = count_db_indexes(home); |
| 9034 | if (index_count <= 0) { |
| 9035 | return 1; /* nothing to handle, proceed */ |
| 9036 | } |
| 9037 | |
| 9038 | if (!reset) { |
| 9039 | /* Default: preserve. Be honest — keep the indexes, advise re-index. */ |
| 9040 | printf("Found %d existing index(es). Keeping them. After install, " |
| 9041 | "re-index to pick up this version's improvements:\n", |
| 9042 | index_count); |
| 9043 | cbm_list_indexes(home); |
| 9044 | printf("\n"); |
| 9045 | return 1; /* proceed without deleting */ |
| 9046 | } |
| 9047 | |
| 9048 | /* Opt-in reset (--reset-indexes): the original prompt-and-delete path. */ |
| 9049 | printf("Found %d existing index(es):\n", index_count); |
| 9050 | cbm_list_indexes(home); |
| 9051 | printf("\n"); |
| 9052 | if (!prompt_yn("Delete these indexes and continue with install?")) { |
| 9053 | printf("Install cancelled.\n"); |
| 9054 | return 0; /* abort */ |
| 9055 | } |
| 9056 | if (!dry_run && delete_indexes_out) { |
| 9057 | *delete_indexes_out = true; |
| 9058 | } |
| 9059 | return 1; /* proceed */ |
| 9060 | } |
| 9061 | |
| 9062 | int cbm_install_handle_existing_indexes(const char *home, bool reset, bool dry_run) { |
| 9063 | bool delete_indexes = false; |
no test coverage detected