aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgit-hulk <hulk.website@gmail.com>2024-05-09 14:42:36 +0800
committerHisham Muhammad <hisham@gobolinux.org>2024-05-14 17:52:04 -0300
commitdc0af58cfccdf21192c91ed358cd732bad8181da (patch)
tree0c7133333f72d69979f903d856f032b5584bd066
parent301926964c2c49cfc42828d07d79109987ab3dbb (diff)
downloadluarocks-dc0af58cfccdf21192c91ed358cd732bad8181da.tar.gz
luarocks-dc0af58cfccdf21192c91ed358cd732bad8181da.tar.bz2
luarocks-dc0af58cfccdf21192c91ed358cd732bad8181da.zip
Fix the open fd might be nil if failing to open in fetch_caching
-rw-r--r--src/luarocks/fetch.lua13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua
index 435108ae..193e5e39 100644
--- a/src/luarocks/fetch.lua
+++ b/src/luarocks/fetch.lua
@@ -62,15 +62,20 @@ function fetch.fetch_caching(url, mirroring)
62 end 62 end
63 63
64 local file, err, errcode, from_cache = fetch.fetch_url(url, cachefile, true, mirroring) 64 local file, err, errcode, from_cache = fetch.fetch_url(url, cachefile, true, mirroring)
65 if not file then
66 fs.unlock_access(lock)
67 return nil, err or "Failed downloading "..url, errcode
68 end
65 69
66 local fd = io.open(checkfile, "wb") 70 local fd, err = io.open(checkfile, "wb")
71 if err then
72 fs.unlock_access(lock)
73 return nil, err
74 end
67 fd:write("!") 75 fd:write("!")
68 fd:close() 76 fd:close()
69 77
70 fs.unlock_access(lock) 78 fs.unlock_access(lock)
71 if not file then
72 return nil, err or "Failed downloading "..url, errcode
73 end
74 return file, nil, nil, from_cache 79 return file, nil, nil, from_cache
75end 80end
76 81