From 444d8301ae07129a531f55994aeec10efaedfa1b Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 19 Feb 2024 19:20:52 -0300 Subject: fix: don't show "no downloader" error for every mirror --- src/luarocks/fetch.lua | 4 ++-- src/luarocks/fs/lua.lua | 2 +- src/luarocks/fs/tools.lua | 8 ++++---- src/luarocks/search.lua | 3 +++ 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index 24b3e1e5..f17a9279 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua @@ -101,7 +101,7 @@ local function download_with_mirrors(url, filename, cache, servers) end end - return nil, err + return nil, err, "network" end --- Fetch a local or remote file. @@ -161,7 +161,7 @@ function fetch.fetch_url(url, filename, cache, mirroring) ok, name, from_cache = fs.download(url, filename, cache) end if not ok then - return nil, "Failed downloading "..url..(name and " - "..name or ""), "network" + return nil, "Failed downloading "..url..(name and " - "..name or ""), from_cache end return name, nil, nil, from_cache else diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index ab32eff8..934bba48 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -944,7 +944,7 @@ function fs_lua.download(url, filename, cache) end return fs.use_downloader(url, filename, cache) elseif not ok then - return nil, err + return nil, err, "network" end return true, filename, from_cache end diff --git a/src/luarocks/fs/tools.lua b/src/luarocks/fs/tools.lua index ff29ea39..a7724dc7 100644 --- a/src/luarocks/fs/tools.lua +++ b/src/luarocks/fs/tools.lua @@ -142,8 +142,8 @@ end -- filename can be given explicitly as this second argument. -- @param cache boolean: compare remote timestamps via HTTP HEAD prior to -- re-downloading the file. --- @return (boolean, string): true and the filename on success, --- false and the error message on failure. +-- @return (boolean, string, string): true and the filename on success, +-- false and the error message and code on failure. function tools.use_downloader(url, filename, cache) assert(type(url) == "string") assert(type(filename) == "string" or not filename) @@ -152,7 +152,7 @@ function tools.use_downloader(url, filename, cache) local downloader, err = fs.which_tool("downloader") if not downloader then - return nil, err + return nil, err, "downloader" end local ok = false @@ -187,7 +187,7 @@ function tools.use_downloader(url, filename, cache) return true, filename else os.remove(filename) - return false, "failed downloading " .. url + return false, "failed downloading " .. url, "network" end end diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua index e76d4591..180f8f45 100644 --- a/src/luarocks/search.lua +++ b/src/luarocks/search.lua @@ -160,6 +160,9 @@ function search.search_repos(query, lua_version) break else util.warning("Failed searching manifest: "..err) + if errcode == "downloader" then + break + end end end end -- cgit v1.2.3-55-g6feb