From bdb3572ac8d0b75f7bce5512cad8f03823d2ace8 Mon Sep 17 00:00:00 2001 From: luau-project Date: Tue, 24 Jun 2025 11:42:16 -0300 Subject: fix: create cache_dir when local_cache exists --- src/luarocks/fetch.lua | 5 ++++- src/luarocks/fetch.tl | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index bcee6f23..50363cc0 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua @@ -49,7 +49,10 @@ function fetch.fetch_caching(url, mirroring) local repo_url, filename = url:match("^(.*)/([^/]+)$") local name = repo_url:gsub("[/:]", "_") local cache_dir = dir.path(cfg.local_cache, name) - local ok = fs.make_dir(cache_dir) + local ok = fs.exists(cfg.local_cache) + if ok then + ok = fs.make_dir(cache_dir) + end local cachefile = dir.path(cache_dir, filename) local checkfile = cachefile .. ".check" diff --git a/src/luarocks/fetch.tl b/src/luarocks/fetch.tl index 2f81ac0c..75f0a157 100644 --- a/src/luarocks/fetch.tl +++ b/src/luarocks/fetch.tl @@ -49,12 +49,15 @@ function fetch.fetch_caching(url: string, mirroring?: string): string, string, s local repo_url, filename = url:match("^(.*)/([^/]+)$") local name = repo_url:gsub("[/:]","_") local cache_dir = dir.path(cfg.local_cache, name) - local ok = fs.make_dir(cache_dir) + local ok = fs.exists(cfg.local_cache) + if ok then + ok = fs.make_dir(cache_dir) + end local cachefile = dir.path(cache_dir, filename) local checkfile = cachefile .. ".check" - if (fs.file_age(checkfile) < 10 or + if (fs.exists(checkfile) and fs.file_age(checkfile) < 10 or cfg.aggressive_cache and (not name:match("^manifest"))) and fs.exists(cachefile) then return cachefile, nil, nil, true @@ -75,6 +78,8 @@ function fetch.fetch_caching(url: string, mirroring?: string): string, string, s if not ok then return nil, "Failed creating temporary cache directory "..cache_dir end + cachefile = dir.path(cache_dir, filename) + checkfile = cachefile .. ".check" lock = fs.lock_access(cache_dir) end -- cgit v1.2.3-55-g6feb