A generic auto-answer is not consent to erase project indexes. An explicit * --delete-indexes takes precedence even over --no; otherwise only a separate * interactive answer can select deletion. This helper decides and reports, * but all deletion remains in the final guarded uninstall activation. */
| 12969 | * interactive answer can select deletion. This helper decides and reports, |
| 12970 | * but all deletion remains in the final guarded uninstall activation. */ |
| 12971 | static bool uninstall_decide_index_deletion(const char *home, bool requested, bool dry_run) { |
| 12972 | int index_count = count_db_indexes(home); |
| 12973 | if (index_count <= 0) { |
| 12974 | return false; |
| 12975 | } |
| 12976 | printf("\nFound %d index(es):\n", index_count); |
| 12977 | cbm_list_indexes(home); |
| 12978 | bool delete_indexes = requested; |
| 12979 | if (!requested) { |
| 12980 | bool can_ask = g_auto_answer == 0; |
| 12981 | #ifdef _WIN32 |
| 12982 | can_ask = can_ask && _isatty(_fileno(stdin)); |
| 12983 | #else |
| 12984 | can_ask = can_ask && isatty(fileno(stdin)); |
| 12985 | #endif |
| 12986 | delete_indexes = can_ask && prompt_yn("Delete these indexes? (default: no)"); |
| 12987 | } |
| 12988 | if (!delete_indexes) { |
| 12989 | const char *cache_dir = get_cache_dir(home); |
| 12990 | printf("Indexes kept in %s. To remove them, uninstall with --delete-indexes " |
| 12991 | "or delete the project .db files there.\n", |
| 12992 | cache_dir ? cache_dir : "the cache directory"); |
| 12993 | return false; |
| 12994 | } |
| 12995 | if (dry_run) { |
| 12996 | printf("(dry-run — indexes would be deleted)\n"); |
| 12997 | return false; |
| 12998 | } |
| 12999 | return true; |
| 13000 | } |
| 13001 | |
| 13002 | int cbm_cmd_uninstall(int argc, char **argv) { |
| 13003 | /* `uninstall --help` used to UNINSTALL. |
no test coverage detected