feat(shell): allow user to specify the cache path with OMP_CACHE_DIR

resolves #4321
This commit is contained in:
Jan De Dobbeleer 2023-10-17 09:08:36 +02:00 committed by Jan De Dobbeleer
parent 0cfe9a7423
commit e15a797640

View file

@ -100,14 +100,22 @@ func (env *Shell) Platform() string {
func (env *Shell) CachePath() string {
defer env.Trace(time.Now())
// allow the user to set the cache path using OMP_CACHE_DIR
if cachePath := returnOrBuildCachePath(env.Getenv("OMP_CACHE_DIR")); len(cachePath) != 0 {
return cachePath
}
// get XDG_CACHE_HOME if present
if cachePath := returnOrBuildCachePath(env.Getenv("XDG_CACHE_HOME")); len(cachePath) != 0 {
return cachePath
}
// HOME cache folder
if cachePath := returnOrBuildCachePath(env.Home() + "/.cache"); len(cachePath) != 0 {
return cachePath
}
return env.Home()
}