Skip to main content

index_dir

Function index_dir 

Source
pub fn index_dir(root: &Path) -> PathBuf
Expand description

Returns the directory that holds ck’s index and sidecar files for a search root.

By default this is <root>/.ck, keeping the index alongside the data it describes. When INDEX_DIR_ENV is set to a non-empty value, the index is relocated to $CK_INDEX_DIR/<basename>-<hash8>, where <basename> is the final component of root and <hash8> is the first 8 hex characters of the blake3 hash of the root’s absolute path. This keeps repositories free of in-tree .ck directories while giving each root a stable, collision- resistant location even when two roots share a basename.

Both the relocation base and the root are absolutized, so the returned path is absolute and independent of the current directory (a relative CK_INDEX_DIR is anchored at the launch directory). The environment variable is read on every call, so callers (and tests) may change it at runtime. An empty value is treated as unset. This function never panics: if a path cannot be made absolute it degrades gracefully (see [absolute_for_hash]).