Index lp->tmpdir (already populated) via the production index_repository flow * and open the resulting graph DB (NULL on failure). */
| 52 | /* Index lp->tmpdir (already populated) via the production index_repository flow |
| 53 | * and open the resulting graph DB (NULL on failure). */ |
| 54 | static inline cbm_store_t *rh_open_indexed(RProj *lp) { |
| 55 | lp->project = cbm_project_name_from_path(lp->tmpdir); |
| 56 | if (!lp->project) |
| 57 | return NULL; |
| 58 | if (!lp->cachedir[0]) { |
| 59 | snprintf(lp->cachedir, sizeof(lp->cachedir), "/tmp/cbm_repro_cache_XXXXXX"); |
| 60 | if (!cbm_mkdtemp(lp->cachedir)) |
| 61 | return NULL; |
| 62 | rh_to_fwd_slashes(lp->cachedir); |
| 63 | } |
| 64 | snprintf(lp->dbpath, sizeof(lp->dbpath), "%s/%s.db", lp->cachedir, lp->project); |
| 65 | unlink(lp->dbpath); |
| 66 | |
| 67 | const char *prior_cache_dir = getenv("CBM_CACHE_DIR"); |
| 68 | char *saved_cache_dir = prior_cache_dir ? cbm_strdup(prior_cache_dir) : NULL; |
| 69 | cbm_setenv("CBM_CACHE_DIR", lp->cachedir, 1); |
| 70 | |
| 71 | cbm_store_t *store = NULL; |
| 72 | lp->srv = cbm_mcp_server_new(NULL); |
| 73 | if (lp->srv) { |
| 74 | char args[700]; |
| 75 | snprintf(args, sizeof(args), "{\"repo_path\":\"%s\"}", lp->tmpdir); |
| 76 | char *resp = cbm_mcp_handle_tool(lp->srv, "index_repository", args); |
| 77 | if (resp) |
| 78 | free(resp); |
| 79 | /* Repro consumers only inspect the graph. Keep this connection query-only |
| 80 | * so the harness does not mutate the publisher's sealed journal mode. */ |
| 81 | store = cbm_store_open_path_query(lp->dbpath); |
| 82 | } |
| 83 | |
| 84 | if (saved_cache_dir) { |
| 85 | cbm_setenv("CBM_CACHE_DIR", saved_cache_dir, 1); |
| 86 | free(saved_cache_dir); |
| 87 | } else { |
| 88 | cbm_unsetenv("CBM_CACHE_DIR"); |
| 89 | } |
| 90 | return store; |
| 91 | } |
| 92 | |
| 93 | static inline void rh_cleanup(RProj *lp, cbm_store_t *store); |
| 94 |
no test coverage detected