MCPcopy Index your code
hub / github.com/perkeep/perkeep / cacheDir

Function cacheDir

internal/osutil/paths.go:61–87  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

59}
60
61func cacheDir() string {
62 if d := os.Getenv("PERKEEP_CACHE_DIR"); d != "" {
63 return d
64 }
65 if d := os.Getenv("CAMLI_CACHE_DIR"); d != "" {
66 return d
67 }
68 failInTests()
69 switch runtime.GOOS {
70 case "darwin":
71 return filepath.Join(HomeDir(), "Library", "Caches", "Camlistore")
72 case "windows":
73 // Per http://technet.microsoft.com/en-us/library/cc749104(v=ws.10).aspx
74 // these should both exist. But that page overwhelms me. Just try them
75 // both. This seems to work.
76 for _, ev := range []string{"TEMP", "TMP"} {
77 if v := os.Getenv(ev); v != "" {
78 return filepath.Join(v, "Perkeep")
79 }
80 }
81 panic("No Windows TEMP or TMP environment variables found; please file a bug report.")
82 }
83 if xdg := os.Getenv("XDG_CACHE_HOME"); xdg != "" {
84 return filepath.Join(xdg, "perkeep")
85 }
86 return filepath.Join(HomeDir(), ".cache", "perkeep")
87}
88
89func makeCacheDir() {
90 err := os.MkdirAll(cacheDir(), 0700)

Callers 2

CacheDirFunction · 0.85
makeCacheDirFunction · 0.85

Calls 2

failInTestsFunction · 0.85
HomeDirFunction · 0.85

Tested by

no test coverage detected