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:9451–9483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9449 */
9450int cbm_install_handle_existing_indexes(const char *home, bool reset, bool dry_run);
9451static 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
9485int cbm_install_handle_existing_indexes(const char *home, bool reset, bool dry_run) {
9486 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