1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! Centralized cache directory resolution for all kreuzberg modules.
//!
//! Provides a single function that all modules use to determine where to store
//! cached data (models, OCR results, tessdata, etc.). This avoids per-CWD
//! `.kreuzberg/` directories and uses platform-appropriate global cache locations.
use PathBuf;
/// Resolve the kreuzberg cache base directory (without a module suffix).
///
/// Uses the same resolution order as [`resolve_cache_dir`] but returns
/// the top-level kreuzberg cache directory.
/// Resolve the kreuzberg cache directory for a given module.
///
/// Resolution order:
/// 1. `KREUZBERG_CACHE_DIR` env var + `/{module}` (explicit override)
/// 2. Platform-appropriate global cache directory:
/// - macOS: `~/Library/Caches/kreuzberg/{module}`
/// - Linux: `$XDG_CACHE_HOME/kreuzberg/{module}` or `~/.cache/kreuzberg/{module}`
/// - Windows: `%LOCALAPPDATA%/kreuzberg/{module}`
/// 3. Home directory fallback: `~/.cache/kreuzberg/{module}`
/// 4. CWD-relative fallback: `.kreuzberg/{module}` (last resort, e.g. no HOME set)