()
| 59 | } |
| 60 | |
| 61 | func 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 | |
| 89 | func makeCacheDir() { |
| 90 | err := os.MkdirAll(cacheDir(), 0700) |
no test coverage detected