diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2014-02-08 18:32:35 -0200 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2014-02-08 18:32:35 -0200 |
commit | e6ebf473e09afed69895e6501580fbc47bf13534 (patch) | |
tree | 0ebd3c0a33d0603ef736408f8f34d2dd69022819 | |
parent | fdf546560b425ae5cfcc18b9b9d4e1e8f3995371 (diff) | |
download | luarocks-e6ebf473e09afed69895e6501580fbc47bf13534.tar.gz luarocks-e6ebf473e09afed69895e6501580fbc47bf13534.tar.bz2 luarocks-e6ebf473e09afed69895e6501580fbc47bf13534.zip |
When a server times out, stop using it and move down the mirrors list.
-rw-r--r-- | src/luarocks/cfg.lua | 1 | ||||
-rw-r--r-- | src/luarocks/fs/lua.lua | 3 | ||||
-rw-r--r-- | src/luarocks/manif.lua | 8 | ||||
-rw-r--r-- | src/luarocks/search.lua | 33 |
4 files changed, 27 insertions, 18 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 484bfb79..f38ae9a8 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
@@ -219,6 +219,7 @@ local defaults = { | |||
219 | "http://luarocks.logiceditor.com/rocks", | 219 | "http://luarocks.logiceditor.com/rocks", |
220 | } | 220 | } |
221 | }, | 221 | }, |
222 | disabled_servers = {}, | ||
222 | 223 | ||
223 | lua_extension = "lua", | 224 | lua_extension = "lua", |
224 | lua_interpreter = site_config.LUA_INTERPRETER or "lua", | 225 | lua_interpreter = site_config.LUA_INTERPRETER or "lua", |
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 6aca2b69..a95e7c51 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
@@ -602,6 +602,9 @@ local function http_request(url, http, cached) | |||
602 | if status == 200 and headers["last-modified"] == timestamp then | 602 | if status == 200 and headers["last-modified"] == timestamp then |
603 | return true | 603 | return true |
604 | end | 604 | end |
605 | if not result then | ||
606 | return nil, status | ||
607 | end | ||
605 | end | 608 | end |
606 | end | 609 | end |
607 | local result, status, headers, err = request(url, "GET", http) | 610 | local result, status, headers, err = request(url, "GET", http) |
diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index 3fb3e4e3..b9a65b09 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua | |||
@@ -129,15 +129,15 @@ function load_manifest(repo_url) | |||
129 | end | 129 | end |
130 | end | 130 | end |
131 | else | 131 | else |
132 | local err | 132 | local err, errcode |
133 | for _, filename in ipairs(filenames) do | 133 | for _, filename in ipairs(filenames) do |
134 | pathname, err = fetch_manifest_from(repo_url, filename) | 134 | pathname, err, errcode = fetch_manifest_from(repo_url, filename) |
135 | if pathname then | 135 | if pathname or errcode == "network" then |
136 | break | 136 | break |
137 | end | 137 | end |
138 | end | 138 | end |
139 | if not pathname then | 139 | if not pathname then |
140 | return nil, err | 140 | return nil, err, errcode |
141 | end | 141 | end |
142 | end | 142 | end |
143 | if pathname:match(".*%.zip$") then | 143 | if pathname:match(".*%.zip$") then |
diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua index bd636352..f0659e0f 100644 --- a/src/luarocks/search.lua +++ b/src/luarocks/search.lua | |||
@@ -170,9 +170,9 @@ function manifest_search(results, repo, query) | |||
170 | assert(type(query) == "table") | 170 | assert(type(query) == "table") |
171 | 171 | ||
172 | query_arch_as_table(query) | 172 | query_arch_as_table(query) |
173 | local manifest, err = manif.load_manifest(repo) | 173 | local manifest, err, errcode = manif.load_manifest(repo) |
174 | if not manifest then | 174 | if not manifest then |
175 | return nil, "Failed loading manifest: "..err | 175 | return nil, err, errcode |
176 | end | 176 | end |
177 | for name, versions in pairs(manifest.repository) do | 177 | for name, versions in pairs(manifest.repository) do |
178 | for version, items in pairs(versions) do | 178 | for version, items in pairs(versions) do |
@@ -194,19 +194,24 @@ function search_repos(query) | |||
194 | 194 | ||
195 | local results = {} | 195 | local results = {} |
196 | for _, repo in ipairs(cfg.rocks_servers) do | 196 | for _, repo in ipairs(cfg.rocks_servers) do |
197 | if type(repo) == "string" then | 197 | if not cfg.disabled_servers[repo] then |
198 | repo = { repo } | 198 | if type(repo) == "string" then |
199 | end | 199 | repo = { repo } |
200 | for _, mirror in ipairs(repo) do | ||
201 | local protocol, pathname = dir.split_url(mirror) | ||
202 | if protocol == "file" then | ||
203 | mirror = pathname | ||
204 | end | 200 | end |
205 | local ok, err = manifest_search(results, mirror, query) | 201 | for _, mirror in ipairs(repo) do |
206 | if ok then | 202 | local protocol, pathname = dir.split_url(mirror) |
207 | break | 203 | if protocol == "file" then |
208 | else | 204 | mirror = pathname |
209 | util.warning("Failed searching manifest: "..err) | 205 | end |
206 | local ok, err, errcode = manifest_search(results, mirror, query) | ||
207 | if errcode == "network" then | ||
208 | cfg.disabled_servers[repo] = true | ||
209 | end | ||
210 | if ok then | ||
211 | break | ||
212 | else | ||
213 | util.warning("Failed searching manifest: "..err) | ||
214 | end | ||
210 | end | 215 | end |
211 | end | 216 | end |
212 | end | 217 | end |