Skip to content

Commit dc919b2

Browse files
committed
Create cache directory before SQLite dump in pipeline
The dump phase writes to ~/.cache/codebase-memory-mcp/<project>.db but the directory may not exist on fresh CI runners. Add cbm_mkdir_p() to ensure the parent directory is created before writing. This fixes smoke test failures where index_repository returned status "error" because the dump phase couldn't create the database file.
1 parent a71a65f commit dc919b2

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/pipeline/pipeline.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "graph_buffer/graph_buffer.h"
1818
#include "discover/discover.h"
1919
#include "foundation/platform.h"
20+
#include "foundation/compat_fs.h"
2021
#include "foundation/log.h"
2122
#include "foundation/hash_table.h"
2223
#include "foundation/compat.h"
@@ -633,6 +634,15 @@ int cbm_pipeline_run(cbm_pipeline_t *p) {
633634
p->project_name);
634635
}
635636

637+
/* Ensure parent directory exists (e.g. ~/.cache/codebase-memory-mcp/) */
638+
char db_dir[1024];
639+
snprintf(db_dir, sizeof(db_dir), "%s", db_path);
640+
char *last_slash = strrchr(db_dir, '/');
641+
if (last_slash) {
642+
*last_slash = '\0';
643+
cbm_mkdir_p(db_dir, 0755);
644+
}
645+
636646
rc = cbm_gbuf_dump_to_sqlite(p->gbuf, db_path);
637647
if (rc != 0) {
638648
cbm_log_error("pipeline.err", "phase", "dump");

0 commit comments

Comments
 (0)