| 3608 | */ |
| 3609 | int cbm_install_handle_existing_indexes(const char *home, bool reset, bool dry_run); |
| 3610 | int cbm_install_handle_existing_indexes(const char *home, bool reset, bool dry_run) { |
| 3611 | int index_count = count_db_indexes(home); |
| 3612 | if (index_count <= 0) { |
| 3613 | return 1; /* nothing to handle, proceed */ |
| 3614 | } |
| 3615 | |
| 3616 | if (!reset) { |
| 3617 | /* Default: preserve. Be honest — keep the indexes, advise re-index. */ |
| 3618 | printf("Found %d existing index(es). Keeping them. After install, " |
| 3619 | "re-index to pick up this version's improvements:\n", |
| 3620 | index_count); |
| 3621 | cbm_list_indexes(home); |
| 3622 | printf("\n"); |
| 3623 | return 1; /* proceed without deleting */ |
| 3624 | } |
| 3625 | |
| 3626 | /* Opt-in reset (--reset-indexes): the original prompt-and-delete path. */ |
| 3627 | printf("Found %d existing index(es):\n", index_count); |
| 3628 | cbm_list_indexes(home); |
| 3629 | printf("\n"); |
| 3630 | if (!prompt_yn("Delete these indexes and continue with install?")) { |
| 3631 | printf("Install cancelled.\n"); |
| 3632 | return 0; /* abort */ |
| 3633 | } |
| 3634 | if (!dry_run) { |
| 3635 | int removed = cbm_remove_indexes(home); |
| 3636 | printf("Removed %d index(es).\n\n", removed); |
| 3637 | } |
| 3638 | return 1; /* proceed */ |
| 3639 | } |
| 3640 | |
| 3641 | /* ── Subcommand: install ──────────────────────────────────────── */ |
| 3642 |
no test coverage detected