aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorV1K1NGbg <victor@ilchev.com>2024-08-06 10:20:56 +0300
committerV1K1NGbg <victor@ilchev.com>2024-08-06 10:20:56 +0300
commit27503e29b8712fdacf5195fa536ee2c50cc2e4c1 (patch)
tree3c59aa14ef20ab320196877ddda07f708c592e67 /src
parent59262556a6701455e788ce7c0827fd0b0a96f9fb (diff)
downloadluarocks-27503e29b8712fdacf5195fa536ee2c50cc2e4c1.tar.gz
luarocks-27503e29b8712fdacf5195fa536ee2c50cc2e4c1.tar.bz2
luarocks-27503e29b8712fdacf5195fa536ee2c50cc2e4c1.zip
fix misaligned return signatures
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/fetch.lua12
-rw-r--r--src/luarocks/fetch.tl12
-rw-r--r--src/luarocks/fs.d.tl2
-rw-r--r--src/luarocks/fs/lua.lua12
-rw-r--r--src/luarocks/fs/tools.lua6
5 files changed, 23 insertions, 21 deletions
diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua
index 193e5e39..0277657b 100644
--- a/src/luarocks/fetch.lua
+++ b/src/luarocks/fetch.lua
@@ -113,7 +113,7 @@ local function download_with_mirrors(url, filename, cache, servers)
113 end 113 end
114 local ok, name, from_cache = fs.download(try_url, filename, cache) 114 local ok, name, from_cache = fs.download(try_url, filename, cache)
115 if ok then 115 if ok then
116 return ok, name, from_cache 116 return name, nil, nil, from_cache
117 else 117 else
118 err = err .. name .. "\n" 118 err = err .. name .. "\n"
119 end 119 end
@@ -172,14 +172,14 @@ function fetch.fetch_url(url, filename, cache, mirroring)
172 return nil, "Failed copying local file " .. fullname .. " to " .. dstname .. ": " .. err 172 return nil, "Failed copying local file " .. fullname .. " to " .. dstname .. ": " .. err
173 end 173 end
174 elseif dir.is_basic_protocol(protocol) then 174 elseif dir.is_basic_protocol(protocol) then
175 local ok, name, from_cache 175 local name, err, err_code, from_cache
176 if mirroring ~= "no_mirror" then 176 if mirroring ~= "no_mirror" then
177 ok, name, from_cache = download_with_mirrors(url, filename, cache, cfg.rocks_servers) 177 name, err, err_code, from_cache = download_with_mirrors(url, filename, cache, cfg.rocks_servers)
178 else 178 else
179 ok, name, from_cache = fs.download(url, filename, cache) 179 name, err, err_code, from_cache = fs.download(url, filename, cache)
180 end 180 end
181 if not ok then 181 if not name then
182 return nil, "Failed downloading "..url..(name and " - "..name or ""), from_cache 182 return nil, "Failed downloading "..url..(err and " - "..err or ""), err_code
183 end 183 end
184 return name, nil, nil, from_cache 184 return name, nil, nil, from_cache
185 else 185 else
diff --git a/src/luarocks/fetch.tl b/src/luarocks/fetch.tl
index 34437f78..2d7ae15a 100644
--- a/src/luarocks/fetch.tl
+++ b/src/luarocks/fetch.tl
@@ -37,7 +37,7 @@ local function is_url_relative_to_rocks_servers(url: string, servers: {{string}}
37 end 37 end
38end 38end
39 39
40local function download_with_mirrors(url: string, filename: string, cache: boolean, servers: {{string}}): boolean, string, string 40local function download_with_mirrors(url: string, filename: string, cache: boolean, servers: {{string}}): string, string, string, boolean
41 local idx, rest, mirrors = is_url_relative_to_rocks_servers(url, servers) 41 local idx, rest, mirrors = is_url_relative_to_rocks_servers(url, servers)
42 42
43 if not idx then 43 if not idx then
@@ -111,14 +111,14 @@ function fetch.fetch_url(url: string, filename?: string, cache?: boolean, mirror
111 return nil, "Failed copying local file " .. fullname .. " to " .. dstname .. ": " .. err 111 return nil, "Failed copying local file " .. fullname .. " to " .. dstname .. ": " .. err
112 end 112 end
113 elseif dir.is_basic_protocol(protocol) then 113 elseif dir.is_basic_protocol(protocol) then
114 local ok, name, from_cache: boolean, string, string | boolean 114 local name, err, err_code, from_cache: string, string, string, boolean
115 if mirroring ~= "no_mirror" then 115 if mirroring ~= "no_mirror" then
116 ok, name, from_cache = download_with_mirrors(url, filename, cache, cfg.rocks_servers) 116 name, err, err_code, from_cache = download_with_mirrors(url, filename, cache, cfg.rocks_servers)
117 else 117 else
118 ok, name, from_cache = fs.download(url, filename, cache) 118 name, err, err_code, from_cache = fs.download(url, filename, cache)
119 end 119 end
120 if not ok then 120 if not name then
121 return nil, "Failed downloading "..url..(name and " - "..name or ""), from_cache 121 return nil, "Failed downloading "..url..(err and " - "..err or ""), err_code
122 end 122 end
123 return name, nil, nil, from_cache --! string or boolean 123 return name, nil, nil, from_cache --! string or boolean
124 else 124 else
diff --git a/src/luarocks/fs.d.tl b/src/luarocks/fs.d.tl
index e5047af7..dcfaa954 100644
--- a/src/luarocks/fs.d.tl
+++ b/src/luarocks/fs.d.tl
@@ -25,7 +25,7 @@ local record fs
25 tmpname: function(): string 25 tmpname: function(): string
26 execute_string: function(string): boolean 26 execute_string: function(string): boolean
27 Q: function(string): string 27 Q: function(string): string
28 download: function(string, string, ?boolean): boolean, string, boolean 28 download: function(string, string, ?boolean): string, string, string, boolean
29 set_permissions: function(string, string, string) 29 set_permissions: function(string, string, string)
30 -- patch 30 -- patch
31 absolute_name: function(string, ?string): string 31 absolute_name: function(string, ?string): string
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua
index 4016ddcd..fdf3af78 100644
--- a/src/luarocks/fs/lua.lua
+++ b/src/luarocks/fs/lua.lua
@@ -936,14 +936,16 @@ local downloader_warning = false
936-- resulting local filename of the remote file as the basename of the URL; 936-- resulting local filename of the remote file as the basename of the URL;
937-- if that is not correct (due to a redirection, for example), the local 937-- if that is not correct (due to a redirection, for example), the local
938-- filename can be given explicitly as this second argument. 938-- filename can be given explicitly as this second argument.
939-- @return (boolean, string, boolean): 939-- @return (string, string, string, boolean):
940-- In case of success: 940-- In case of success:
941-- * true 941-- * name
942-- * a string with the filename 942-- nil
943-- nil
943-- * true if the file was retrieved from local cache 944-- * true if the file was retrieved from local cache
944-- In case of failure: 945-- In case of failure:
945-- * false 946-- nil
946-- * error message 947-- * error message
948-- * error code
947function fs_lua.download(url, filename, cache) 949function fs_lua.download(url, filename, cache)
948 assert(type(url) == "string") 950 assert(type(url) == "string")
949 assert(type(filename) == "string" or not filename) 951 assert(type(filename) == "string" or not filename)
@@ -984,7 +986,7 @@ function fs_lua.download(url, filename, cache)
984 elseif not ok then 986 elseif not ok then
985 return nil, err, "network" 987 return nil, err, "network"
986 end 988 end
987 return true, filename, from_cache 989 return filename, nil, nil, from_cache
988end 990end
989 991
990else --...if socket_ok == false then 992else --...if socket_ok == false then
diff --git a/src/luarocks/fs/tools.lua b/src/luarocks/fs/tools.lua
index 23f2561e..b7d03759 100644
--- a/src/luarocks/fs/tools.lua
+++ b/src/luarocks/fs/tools.lua
@@ -148,7 +148,7 @@ end
148-- filename can be given explicitly as this second argument. 148-- filename can be given explicitly as this second argument.
149-- @param cache boolean: compare remote timestamps via HTTP HEAD prior to 149-- @param cache boolean: compare remote timestamps via HTTP HEAD prior to
150-- re-downloading the file. 150-- re-downloading the file.
151-- @return (boolean, string, string): true and the filename on success, 151-- @return (string, string, string): filename on success,
152-- false and the error message and code on failure. 152-- false and the error message and code on failure.
153function tools.use_downloader(url, filename, cache) 153function tools.use_downloader(url, filename, cache)
154 assert(type(url) == "string") 154 assert(type(url) == "string")
@@ -190,10 +190,10 @@ function tools.use_downloader(url, filename, cache)
190 ok = fs.execute_string(fs.quiet_stderr(curl_cmd..fs.Q(url).." --output "..fs.Q(filename))) 190 ok = fs.execute_string(fs.quiet_stderr(curl_cmd..fs.Q(url).." --output "..fs.Q(filename)))
191 end 191 end
192 if ok then 192 if ok then
193 return true, filename 193 return filename
194 else 194 else
195 os.remove(filename) 195 os.remove(filename)
196 return false, "failed downloading " .. url, "network" 196 return nil, "failed downloading " .. url, "network"
197 end 197 end
198end 198end
199 199