From 882c7b1ff2df7a7b05f42eb0ba6f781d9ccfe5fe Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Fri, 16 Feb 2024 23:41:43 -0300 Subject: fix: handle error when failing to create local_cache Closes #1514. Co-Authored-By: FractalU --- src/luarocks/fetch.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index 09f7a40b..24b3e1e5 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua @@ -36,6 +36,9 @@ function fetch.fetch_caching(url, mirroring) local lock = ok and fs.lock_access(cache_dir) if not (ok and lock) then cfg.local_cache = fs.make_temp_dir("local_cache") + if not cfg.local_cache then + return nil, "Failed creating temporary local_cache directory" + end cache_dir = dir.path(cfg.local_cache, name) ok = fs.make_dir(cache_dir) if not ok then @@ -209,7 +212,9 @@ function fetch.fetch_url_at_temp_dir(url, tmpname, filename, cache) file = dir.path(temp_dir, filename) fs.copy(cachefile, file) end - else + end + + if not file then file, err, errcode = fetch.fetch_url(url, filename, cache) end -- cgit v1.2.3-55-g6feb