aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorAdam Vandenberg2013-05-12 13:42:37 -0700
committerAdam Vandenberg2013-05-13 07:32:03 -0700
commit13c604035b93a7e7c4c2d9bbb719d67d6d976c17 (patch)
tree594ce03d8d0ddb443a9897c273d75f3e908ef874 /Library
parent46f8be1d9ed12aa54cd472f2ae70aef7c6e35e6b (diff)
downloadbrew-13c604035b93a7e7c4c2d9bbb719d67d6d976c17.tar.bz2
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.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/download_strategy.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index d1564f977..67261af2a 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -69,10 +69,20 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
ohai "Downloading #{@url}"
unless @tarball_path.exist?
+ had_incomplete_download = @temporary_path.exist?
begin
_fetch
rescue ErrorDuringExecution
- raise CurlDownloadStrategyError, "Download failed: #{@url}"
+ # 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}"
+ end
end
ignore_interrupts { @temporary_path.rename(@tarball_path) }
else