diff options
author | Erica Mays <[email protected]> | 2023-06-10 13:25:07 -0400 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2023-06-12 21:33:35 +0200 |
commit | 258884f44fc3ea6e4954936ddeb24e739eb8f58a (patch) | |
tree | 3f96e643dd97f0ebe275f49daa780dae7954d20a /helpers | |
parent | 254c2b323cbc74b0decb29e5f7331f4b03914a9e (diff) | |
download | hugo-258884f44fc3ea6e4954936ddeb24e739eb8f58a.tar.gz hugo-258884f44fc3ea6e4954936ddeb24e739eb8f58a.zip |
cache: Set default cache path based on $USER
Change the default cache directory to `$TMPDIR/hugo_cache_$USER`, so
that multi-user systems do not have caches that interfere with each
other. The other cache-choosing logic (e.g. Netlify exceptions,
configuration options) are not affected.
Fixes #7391
Diffstat (limited to 'helpers')
-rw-r--r-- | helpers/path.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/helpers/path.go b/helpers/path.go index 00c541bab..4c2799ac2 100644 --- a/helpers/path.go +++ b/helpers/path.go @@ -409,7 +409,12 @@ func GetCacheDir(fs afero.Fs, cacheDir string) (string, error) { } // Fall back to a cache in /tmp. - return GetTempDir("hugo_cache", fs), nil + userName := os.Getenv("USER") + if userName != "" { + return GetTempDir("hugo_cache_"+userName, fs), nil + } else { + return GetTempDir("hugo_cache", fs), nil + } } func cacheDirDefault(cacheDir string) string { |