Skip to content

Commit afaeb74

Browse files
authored
os: create the folder described by XDG_CACHE_HOME, *if it is non empty, and it does not exist yet*, when calling os.cache_dir() (#20046)
1 parent 300158d commit afaeb74

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

vlib/os/os.v

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,9 @@ pub fn cache_dir() string {
733733
// or empty, a default equal to $HOME/.cache should be used.
734734
xdg_cache_home := getenv('XDG_CACHE_HOME')
735735
if xdg_cache_home != '' {
736+
if !is_dir(xdg_cache_home) && !is_link(xdg_cache_home) {
737+
mkdir_all(xdg_cache_home, mode: 0o700) or { panic(err) }
738+
}
736739
return xdg_cache_home
737740
}
738741
cdir := join_path_single(home_dir(), '.cache')

0 commit comments

Comments
 (0)