Skip to content

Commit

Permalink
feat(shell): allow user to specify the cache path with OMP_CACHE_DIR
Browse files Browse the repository at this point in the history
resolves #4321
  • Loading branch information
JanDeDobbeleer committed Oct 17, 2023
1 parent db5cd3e commit 0237901
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/platform/shell_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down

0 comments on commit 0237901

Please sign in to comment.