devclean/scanner/
global_caches.rs1use std::env;
2use std::path::{Path, PathBuf};
3
4#[must_use]
6pub fn global_cache_paths(home: &Path) -> Vec<PathBuf> {
7 let mut paths = [
8 ".npm/_cacache",
9 ".npm/_npx",
10 ".cargo/registry/cache",
11 ".cargo/registry/src",
12 ".cargo/registry/index",
13 ".cargo/git/db",
14 "go/pkg/mod",
15 ".cache/uv",
16 ".cache/pip",
17 ".cache/puppeteer",
18 ".cache/gem",
19 ".pub-cache/hosted",
20 ".pub-cache/hosted-hashes",
21 ".pub-cache/git",
22 ]
23 .into_iter()
24 .map(|relative| home.join(relative))
25 .collect::<Vec<_>>();
26 if let Some(path) = env::var_os("GOMODCACHE").map(PathBuf::from) {
27 if path.is_absolute() && !paths.contains(&path) {
28 paths.push(path);
29 }
30 }
31 if cfg!(target_os = "macos") {
32 paths.extend(
33 [
34 "Library/pnpm",
35 "Library/Caches/ms-playwright",
36 "Library/Caches/node-gyp",
37 ]
38 .into_iter()
39 .map(|relative| home.join(relative)),
40 );
41 }
42 if cfg!(target_os = "windows") {
43 paths.extend(
44 [
45 "AppData/Local/npm-cache",
46 "AppData/Local/pnpm/store",
47 "AppData/Local/ms-playwright",
48 "AppData/Local/node-gyp/Cache",
49 ]
50 .into_iter()
51 .map(|relative| home.join(relative)),
52 );
53 }
54 paths
55}
56
57#[must_use]
59pub fn expensive_global_cache_paths(home: &Path) -> Vec<PathBuf> {
60 [
61 ".cache/codex-runtimes",
62 ".cache/huggingface",
63 ".cache/whisper",
64 ]
65 .into_iter()
66 .map(|relative| home.join(relative))
67 .collect()
68}