diff --git a/lib/maptool/pmtiles_builder.rb b/lib/maptool/pmtiles_builder.rb index de586e8..872d9db 100644 --- a/lib/maptool/pmtiles_builder.rb +++ b/lib/maptool/pmtiles_builder.rb @@ -629,9 +629,16 @@ module Maptool end private_class_method :command_output - def self.run_pmtiles!(*args) - stdout, stderr, status = Open3.capture3(pmtiles_bin, *args) - raise BuildError, "pmtiles exited with status #{status.exitstatus}: #{command_output(stdout, stderr)}" unless status.success? + # extract/merge stream tens of GB over HTTP range requests; retry a + # transient failure (e.g. a mid-transfer HTTP/2 stream reset from the + # remote) a couple times before giving up, rather than forcing a full + # re-download on every hiccup. + def self.run_pmtiles!(*args, attempts: 3) + attempts.times do |i| + stdout, stderr, status = Open3.capture3(pmtiles_bin, *args) + return if status.success? + raise BuildError, "pmtiles exited with status #{status.exitstatus}: #{command_output(stdout, stderr)}" if i == attempts - 1 + end rescue Errno::ENOENT, Errno::EACCES => e raise BuildError, "could not run '#{pmtiles_bin}' (#{e.message}) — is go-pmtiles installed and on PATH? See docs/development.adoc." end