diff --git a/internal/osutil/paths.go b/internal/osutil/paths.go index 3b5be1b33..ae1123e36 100644 --- a/internal/osutil/paths.go +++ b/internal/osutil/paths.go @@ -59,6 +59,9 @@ func CacheDir() string { } func cacheDir() string { + if d := os.Getenv("PERKEEP_CACHE_DIR"); d != "" { + return d + } if d := os.Getenv("CAMLI_CACHE_DIR"); d != "" { return d } @@ -72,15 +75,15 @@ func cacheDir() string { // both. This seems to work. for _, ev := range []string{"TEMP", "TMP"} { if v := os.Getenv(ev); v != "" { - return filepath.Join(v, "Camlistore") + return filepath.Join(v, "Perkeep") } } panic("No Windows TEMP or TMP environment variables found; please file a bug report.") } if xdg := os.Getenv("XDG_CACHE_HOME"); xdg != "" { - return filepath.Join(xdg, "camlistore") + return filepath.Join(xdg, "perkeep") } - return filepath.Join(HomeDir(), ".cache", "camlistore") + return filepath.Join(HomeDir(), ".cache", "perkeep") } func makeCacheDir() { diff --git a/pkg/fs/fs_test.go b/pkg/fs/fs_test.go index 9164ee394..b7083a4e9 100644 --- a/pkg/fs/fs_test.go +++ b/pkg/fs/fs_test.go @@ -142,15 +142,7 @@ func pkmountTest(t *testing.T, fn func(env *mountEnv)) { defer log.SetOutput(os.Stderr) w := test.GetWorld(t) - mountPoint, err := ioutil.TempDir("", "fs-test-mount") - if err != nil { - t.Fatal(err) - } - defer func() { - if err := os.RemoveAll(mountPoint); err != nil { - t.Fatal(err) - } - }() + mountPoint := t.TempDir() verbose := "false" var stderrDest io.Writer = ioutil.Discard if v, _ := strconv.ParseBool(os.Getenv("VERBOSE_FUSE")); v { @@ -161,7 +153,15 @@ func pkmountTest(t *testing.T, fn func(env *mountEnv)) { stderrDest = io.MultiWriter(stderrDest, os.Stderr) } - mount := w.Cmd("pk-mount", "--debug="+verbose, mountPoint) + mount := w.CmdWithEnv( + "pk-mount", + append( + os.Environ(), + "PERKEEP_CACHE_DIR="+t.TempDir(), + ), + "--debug="+verbose, + mountPoint, + ) mount.Stderr = stderrDest mount.Env = append(mount.Env, "CAMLI_TRACK_FS_STATS=1")