Retry downloads if a server doesn't support byte ranges
If an incomplete download exists, and the HTTP server doesn't support byte ranges, delete the incomplete download and retry once. Tested with freeling, whose server does not support byte ranges. Closes Homebrew/homebrew#19757.
This commit is contained in:
parent
46f8be1d9e
commit
13c604035b
@ -69,11 +69,21 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
|
|||||||
|
|
||||||
ohai "Downloading #{@url}"
|
ohai "Downloading #{@url}"
|
||||||
unless @tarball_path.exist?
|
unless @tarball_path.exist?
|
||||||
|
had_incomplete_download = @temporary_path.exist?
|
||||||
begin
|
begin
|
||||||
_fetch
|
_fetch
|
||||||
rescue ErrorDuringExecution
|
rescue ErrorDuringExecution
|
||||||
|
# 33 == range not supported
|
||||||
|
# try wiping the incomplete download and retrying once
|
||||||
|
if $?.exitstatus == 33 && had_incomplete_download
|
||||||
|
ohai "Trying a full download"
|
||||||
|
@temporary_path.unlink
|
||||||
|
had_incomplete_download = false
|
||||||
|
retry
|
||||||
|
else
|
||||||
raise CurlDownloadStrategyError, "Download failed: #{@url}"
|
raise CurlDownloadStrategyError, "Download failed: #{@url}"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
ignore_interrupts { @temporary_path.rename(@tarball_path) }
|
ignore_interrupts { @temporary_path.rename(@tarball_path) }
|
||||||
else
|
else
|
||||||
puts "Already downloaded: #{@tarball_path}"
|
puts "Already downloaded: #{@tarball_path}"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user