MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / uninstall_decide_index_deletion

Function uninstall_decide_index_deletion

src/cli/cli.c:12971–13000  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

12969 * interactive answer can select deletion. This helper decides and reports,
12970 * but all deletion remains in the final guarded uninstall activation. */
12971static 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
13002int cbm_cmd_uninstall(int argc, char **argv) {
13003 /* `uninstall --help` used to UNINSTALL.

Callers 1

cbm_cmd_uninstallFunction · 0.85

Calls 4

count_db_indexesFunction · 0.85
cbm_list_indexesFunction · 0.85
prompt_ynFunction · 0.85
get_cache_dirFunction · 0.85

Tested by

no test coverage detected