| 9449 | */ |
| 9450 | int cbm_install_handle_existing_indexes(const char *home, bool reset, bool dry_run); |
| 9451 | static int cbm_install_prepare_existing_indexes(const char *home, bool reset, bool dry_run, |
| 9452 | bool *delete_indexes_out) { |
| 9453 | if (delete_indexes_out) { |
| 9454 | *delete_indexes_out = false; |
| 9455 | } |
| 9456 | int index_count = count_db_indexes(home); |
| 9457 | if (index_count <= 0) { |
| 9458 | return 1; /* nothing to handle, proceed */ |
| 9459 | } |
| 9460 | |
| 9461 | if (!reset) { |
| 9462 | /* Default: preserve. Be honest — keep the indexes, advise re-index. */ |
| 9463 | printf("Found %d existing index(es). Keeping them. After install, " |
| 9464 | "re-index to pick up this version's improvements:\n", |
| 9465 | index_count); |
| 9466 | cbm_list_indexes(home); |
| 9467 | printf("\n"); |
| 9468 | return 1; /* proceed without deleting */ |
| 9469 | } |
| 9470 | |
| 9471 | /* Opt-in reset (--reset-indexes): the original prompt-and-delete path. */ |
| 9472 | printf("Found %d existing index(es):\n", index_count); |
| 9473 | cbm_list_indexes(home); |
| 9474 | printf("\n"); |
| 9475 | if (!prompt_yn("Delete these indexes and continue with install?")) { |
| 9476 | printf("Install cancelled.\n"); |
| 9477 | return 0; /* abort */ |
| 9478 | } |
| 9479 | if (!dry_run && delete_indexes_out) { |
| 9480 | *delete_indexes_out = true; |
| 9481 | } |
| 9482 | return 1; /* proceed */ |
| 9483 | } |
| 9484 | |
| 9485 | int cbm_install_handle_existing_indexes(const char *home, bool reset, bool dry_run) { |
| 9486 | bool delete_indexes = false; |
no test coverage detected