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

Function capture_existing_adr

src/pipeline/pipeline.c:1337–1369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1335}
1336
1337static int capture_existing_adr(cbm_pipeline_t *p, const char *db_path) {
1338#if defined(CBM_INCREMENTAL_TEST_API) && CBM_INCREMENTAL_TEST_API
1339 if (atomic_exchange(&g_persist_test_fail_adr_capture, false)) {
1340 return CBM_PIPELINE_ABORT_PRESERVE_DB;
1341 }
1342#endif
1343 cbm_store_t *adr_store = cbm_store_open_path_query(db_path);
1344 if (!adr_store) {
1345 return CBM_PIPELINE_ABORT_PRESERVE_DB;
1346 }
1347 cbm_adr_t existing = {0};
1348 int adr_rc = cbm_store_adr_get(adr_store, p->project_name, &existing);
1349 if (adr_rc == CBM_STORE_NOT_FOUND) {
1350 cbm_store_close(adr_store);
1351 free(p->saved_adr);
1352 p->saved_adr = NULL;
1353 return 0;
1354 }
1355 if (adr_rc != CBM_STORE_OK || !existing.content) {
1356 cbm_store_adr_free(&existing);
1357 cbm_store_close(adr_store);
1358 return CBM_PIPELINE_ABORT_PRESERVE_DB;
1359 }
1360 char *saved = strdup(existing.content);
1361 cbm_store_adr_free(&existing);
1362 cbm_store_close(adr_store);
1363 if (!saved) {
1364 return CBM_PIPELINE_ABORT_PRESERVE_DB;
1365 }
1366 free(p->saved_adr);
1367 p->saved_adr = saved;
1368 return 0;
1369}
1370
1371/* Route an existing generation. Full rebuilds never delete the live DB here:
1372 * publication owns the eventual atomic replacement after every pass and

Callers 1

Calls 4

cbm_store_adr_getFunction · 0.85
cbm_store_closeFunction · 0.85
cbm_store_adr_freeFunction · 0.85

Tested by

no test coverage detected