| 9076 | */ |
| 9077 | int cbm_install_handle_existing_indexes(const char *home, bool reset, bool dry_run); |
| 9078 | static int cbm_install_prepare_existing_indexes(const char *home, bool reset, bool dry_run, |
| 9079 | bool *delete_indexes_out) { |
| 9080 | if (delete_indexes_out) { |
| 9081 | *delete_indexes_out = false; |
| 9082 | } |
| 9083 | int index_count = count_db_indexes(home); |
| 9084 | if (index_count <= 0) { |
| 9085 | return 1; /* nothing to handle, proceed */ |
| 9086 | } |
| 9087 | |
| 9088 | if (!reset) { |
| 9089 | /* Default: preserve. Be honest — keep the indexes, advise re-index. */ |
| 9090 | printf("Found %d existing index(es). Keeping them. After install, " |
| 9091 | "re-index to pick up this version's improvements:\n", |
| 9092 | index_count); |
| 9093 | cbm_list_indexes(home); |
| 9094 | printf("\n"); |
| 9095 | return 1; /* proceed without deleting */ |
| 9096 | } |
| 9097 | |
| 9098 | /* Opt-in reset (--reset-indexes): the original prompt-and-delete path. */ |
| 9099 | printf("Found %d existing index(es):\n", index_count); |
| 9100 | cbm_list_indexes(home); |
| 9101 | printf("\n"); |
| 9102 | if (!prompt_yn("Delete these indexes and continue with install?")) { |
| 9103 | printf("Install cancelled.\n"); |
| 9104 | return 0; /* abort */ |
| 9105 | } |
| 9106 | if (!dry_run && delete_indexes_out) { |
| 9107 | *delete_indexes_out = true; |
| 9108 | } |
| 9109 | return 1; /* proceed */ |
| 9110 | } |
| 9111 | |
| 9112 | int cbm_install_handle_existing_indexes(const char *home, bool reset, bool dry_run) { |
| 9113 | bool delete_indexes = false; |
no test coverage detected