Commit 1ca2a04
committed
feat(ck-core): add CK_INDEX_DIR to relocate index directories out of the source tree
By default ck stores each search root's index in an in-tree `.ck/` directory.
That is convenient but not always wanted: it clutters repositories, can't be
shared between multiple checkouts of the same tree, and is awkward to cache in
CI. When `CK_INDEX_DIR` is set, the index for a search root instead lives at
`$CK_INDEX_DIR/<basename>-<hash>`, where `<hash>` is the first 8 hex characters
of the blake3 hash of the root's absolute path so two roots that share a
basename never collide. Unset preserves the existing `<root>/.ck` behavior
exactly.
Introduce two documented helpers in ck-core: `index_dir(root)` returns the
index/sidecar directory for a search root and `index_exists(root)` reports
whether it exists. Both the relocation base and the root are absolutized, so the
returned path is independent of the current directory (a relative CK_INDEX_DIR
is anchored at the launch directory rather than resolved per-process). The
environment variable is read on every call (an empty value is treated as unset)
and never panics. Every call site that computed `<root>/.ck` — across ck-index,
ck-engine, ck-cli, ck-tui, and ck-core's own sidecar and PDF content-cache
paths, including the walk-ups that probe for a nearby index — now routes through
these helpers. The `.ck` default-exclude pattern and sidecar file extensions are
unchanged.
Because an 8-hex hash can in principle collide, a relocated index directory
records its search root in a `root_path` marker file; indexing refuses to write
into a directory claimed by a different root, and searches refuse to serve one,
surfacing a clear error instead of silently returning another root's results.
Tests covering env-dependent paths are serialized with serial_test (already used
elsewhere in ck) and clear the variable so they exercise default behavior
deterministically.
Documented under "Index Storage" in the README.1 parent d2cfe11 commit 1ca2a04
15 files changed
Lines changed: 449 additions & 78 deletions
File tree
- ck-cli
- src
- tests
- ck-core
- src
- ck-engine/src
- ck-index
- src
- ck-tui/src
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
420 | 420 | | |
421 | 421 | | |
422 | 422 | | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
423 | 440 | | |
424 | 441 | | |
425 | 442 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
513 | 513 | | |
514 | 514 | | |
515 | 515 | | |
516 | | - | |
| 516 | + | |
517 | 517 | | |
518 | 518 | | |
519 | 519 | | |
| |||
978 | 978 | | |
979 | 979 | | |
980 | 980 | | |
981 | | - | |
| 981 | + | |
982 | 982 | | |
983 | 983 | | |
984 | 984 | | |
| |||
1143 | 1143 | | |
1144 | 1144 | | |
1145 | 1145 | | |
1146 | | - | |
| 1146 | + | |
1147 | 1147 | | |
1148 | 1148 | | |
1149 | 1149 | | |
| |||
1183 | 1183 | | |
1184 | 1184 | | |
1185 | 1185 | | |
1186 | | - | |
| 1186 | + | |
1187 | 1187 | | |
1188 | 1188 | | |
1189 | 1189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1650 | 1650 | | |
1651 | 1651 | | |
1652 | 1652 | | |
1653 | | - | |
| 1653 | + | |
1654 | 1654 | | |
1655 | 1655 | | |
1656 | 1656 | | |
| |||
1703 | 1703 | | |
1704 | 1704 | | |
1705 | 1705 | | |
1706 | | - | |
| 1706 | + | |
1707 | 1707 | | |
1708 | 1708 | | |
1709 | 1709 | | |
| |||
0 commit comments