diff options
| author | Markus Reiter | 2017-09-10 07:23:18 +0200 |
|---|---|---|
| committer | Markus Reiter | 2017-09-10 07:23:18 +0200 |
| commit | 1f66c9c9e0b678cc8f7b72d12f29ab6d25bd8eb8 (patch) | |
| tree | 42510d1416b7c7c0aee8ea60c6a230375d481e6a /Library | |
| parent | 914378cf2ef8104a4659772945e5f77945ea16cd (diff) | |
| download | brew-1f66c9c9e0b678cc8f7b72d12f29ab6d25bd8eb8.tar.bz2 | |
Let `curl_download` handle HTTP 416 error.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 12 | ||||
| -rw-r--r-- | Library/Homebrew/utils/curl.rb | 5 |
2 files changed, 5 insertions, 12 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index adeb0a02a..7012fccc8 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -331,20 +331,10 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy if cached_location.exist? puts "Already downloaded: #{cached_location}" else - had_incomplete_download = temporary_path.exist? begin _fetch rescue ErrorDuringExecution - # 33 == range not supported - # try wiping the incomplete download and retrying once - unless $CHILD_STATUS.exitstatus == 33 && had_incomplete_download - raise CurlDownloadStrategyError, @url - end - - ohai "Trying a full download" - temporary_path.unlink - had_incomplete_download = false - retry + raise CurlDownloadStrategyError, @url end ignore_interrupts { temporary_path.rename(cached_location) } end diff --git a/Library/Homebrew/utils/curl.rb b/Library/Homebrew/utils/curl.rb index bc7055c0c..7807d2034 100644 --- a/Library/Homebrew/utils/curl.rb +++ b/Library/Homebrew/utils/curl.rb @@ -38,11 +38,14 @@ def curl(*args) end def curl_download(*args, to: nil, continue_at: "-", **options) + had_incomplete_download ||= File.exist?(to) curl("--location", "--remote-time", "--continue-at", continue_at.to_s, "--output", to, *args, **options) rescue ErrorDuringExecution # `curl` error 33: HTTP server doesn't seem to support byte ranges. Cannot resume. - if $CHILD_STATUS.exitstatus == 33 && continue_at == "-" + # HTTP status 416: Requested range not satisfiable + if ($CHILD_STATUS.exitstatus == 33 || had_incomplete_download) && continue_at == "-" continue_at = 0 + had_incomplete_download = false retry end |
