Atomic, EOF-checked extract downloads; Apply starts builds one after another so routing waits for the offline map's downloads

This commit is contained in:
randy committed 2026-11-13 22:28:37 +01:00
1 parent bf912b96e5
commit d93c77727f
3 files changed
+58 -2

No files matched your search

+13 -1
View File
@@ -543,11 +543,23 @@ module Maptool
last_modified = nil
redirect_to = nil
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") do |http|
# Net::HTTP's default (true) quietly accepts a body cut short of
# its Content-Length; a dropped connection must fail the download.
http.ignore_eof = false
http.request_get(uri) do |response|
case response
when Net::HTTPSuccess
last_modified = response["last-modified"]
File.open(dest, "wb") { |file| response.read_body { |chunk| file.write(chunk) } }
# Into a .part file renamed at the end: an interrupted download
# never leaves a truncated extract behind its old stamp, and a
# routing build that hard-linked the old file keeps reading
# that complete old file (see docs/routing-design.adoc).
begin
File.open("#{dest}.part", "wb") { |file| response.read_body { |chunk| file.write(chunk) } }
File.rename("#{dest}.part", dest)
ensure
FileUtils.rm_f("#{dest}.part")
end
when Net::HTTPRedirection
redirect_to = URI.join(url, response["location"]).to_s
else