Skip to content

Commit 4f15575

Browse files
authored
fix(db): resolve directory paths in findDbPath to .codegraph/graph.db (#1706)
* fix(db): resolve directory paths in findDbPath to .codegraph/graph.db When --db is passed a directory (the documented usage), findDbPath returned the directory verbatim. SQLite then threw "disk I/O error" trying to open a directory as a database file — breaking every read command (stats, query, map, cycles, triage, etc.) while build was unaffected (pipeline.ts appends the path itself). Fix: detect if the resolved path is an existing directory and append .codegraph/graph.db, matching the layout that `build` creates. Paths that are explicit file paths or don't exist yet are returned unchanged. Closes #1705 * fix(db): handle .codegraph dir input and fix config-root derivation (#1706) Two bugs in directory-path handling for --db: 1. When the caller passes the .codegraph directory itself (e.g. --db /repo/.codegraph), findDbPath was treating it as a repo root and returning /repo/.codegraph/.codegraph/graph.db. Now detects basename === '.codegraph' and appends only graph.db. 2. rootDir derivation in openRepo/openReadonlyWithNative was computing path.dirname(path.dirname(path.resolve(customDbPath))) on the raw input, so --db /path/to/repo stripped two levels off the repo dir (yielding /path) instead of the repo root. Fixed by deriving rootDir from the already-resolved findDbPath output. Add two unit tests covering both edge cases. Impact: 3 functions changed, 133 affected
1 parent fb61cf2 commit 4f15575

3 files changed

Lines changed: 473 additions & 7 deletions

File tree

0 commit comments

Comments
 (0)