summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-07-27 20:59:47 +0200
committerGitHub <noreply@github.com>2023-07-27 20:59:47 +0200
commitb3f10556f0ab8a92bdd92e25c67685947317d188 (patch)
tree61faa97a403aec86207bd50d8aa9b815dc3aa579 /config
parent4d7af757c99a561744c87c477d10b89e5c9d7e35 (diff)
Use os.UserCacheDir as first fallback if cacheDir is not set
We will now try 1. cacheDir (or, commonly set in environment as `HUGO_CACHEDIR`) 2. if on Netlify we use `/opt/build/cache/hugo_cache/` 3. os.UserCacheDir 4. A temp dir Storing the cache, especially the module cache, in a temporary idea has had lots of hard to debug issues, especially on MacOS, which this commit tries to fix. This should also make it easier to locate the Hugo cache: >UserCacheDir returns the default root directory to use for user-specific cached data. Users should create their own application-specific subdirectory within this one and use that. > >On Unix systems, it returns $XDG_CACHE_HOME as specified by https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html if non-empty, else $HOME/.cache. On Darwin, it returns $HOME/Library/Caches. On Windows, it returns %LocalAppData%. On Plan 9, it returns $home/lib/cache. > >If the location cannot be determined (for example, $HOME is not defined), then it will return an error. Fixes #11286 Fixes #11291
Diffstat (limited to 'config')
-rw-r--r--config/allconfig/allconfig.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/config/allconfig/allconfig.go b/config/allconfig/allconfig.go
index 72f2883f2..ec95f5eba 100644
--- a/config/allconfig/allconfig.go
+++ b/config/allconfig/allconfig.go
@@ -729,6 +729,7 @@ func fromLoadConfigResult(fs afero.Fs, logger loggers.Logger, res config.LoadCon
cfg := res.Cfg
all := &Config{}
+
err := decodeConfigFromParams(fs, bcfg, cfg, all, nil)
if err != nil {
return nil, err
@@ -871,6 +872,10 @@ func fromLoadConfigResult(fs afero.Fs, logger loggers.Logger, res config.LoadCon
bcfg.PublishDir = all.PublishDir
res.BaseConfig = bcfg
+ all.CommonDirs.CacheDir = bcfg.CacheDir
+ for _, l := range langConfigs {
+ l.CommonDirs.CacheDir = bcfg.CacheDir
+ }
cm := &Configs{
Base: all,