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

Function cbm_install_prepare_existing_indexes

src/cli/cli.c:9078–9110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9076 */
9077int cbm_install_handle_existing_indexes(const char *home, bool reset, bool dry_run);
9078static 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
9112int cbm_install_handle_existing_indexes(const char *home, bool reset, bool dry_run) {
9113 bool delete_indexes = false;

Callers 2

cbm_cmd_installFunction · 0.85

Calls 3

count_db_indexesFunction · 0.85
cbm_list_indexesFunction · 0.85
prompt_ynFunction · 0.85

Tested by

no test coverage detected