diff options
| author | Mike McQuaid | 2014-03-01 12:28:45 +0000 | 
|---|---|---|
| committer | Mike McQuaid | 2014-03-01 16:45:31 +0000 | 
| commit | e695642df0c555f1d4881bf36db57ddc7a6bd2e5 (patch) | |
| tree | 58e72db74870ace8d8d07fa061e761aa759190e6 /Library/Homebrew/cmd/fetch.rb | |
| parent | d8d5cb540a4147311d48f02009b9060f3756a377 (diff) | |
| download | homebrew-e695642df0c555f1d4881bf36db57ddc7a6bd2e5.tar.bz2 | |
fetch: add --retry option to retry fetch once.
Sometimes there may be intermittent failures with hosts that work if
immediately retried. Let's allow a single retry in this case with the
--retry flag. This also behaves nicely with the --force flag.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library/Homebrew/cmd/fetch.rb')
| -rw-r--r-- | Library/Homebrew/cmd/fetch.rb | 18 | 
1 files changed, 16 insertions, 2 deletions
| diff --git a/Library/Homebrew/cmd/fetch.rb b/Library/Homebrew/cmd/fetch.rb index 1fcc5b28e..0a59c6540 100644 --- a/Library/Homebrew/cmd/fetch.rb +++ b/Library/Homebrew/cmd/fetch.rb @@ -28,19 +28,33 @@ module Homebrew extend self      puts "Resource: #{r.name}"      fetch_fetchable r    rescue ChecksumMismatchError => e -    Homebrew.failed = true +    retry if retry_fetch? f      opoo "Resource #{r.name} reports different #{e.hash_type}: #{e.expected}"    end    def fetch_formula f      fetch_fetchable f    rescue ChecksumMismatchError => e -    Homebrew.failed = true +    retry if retry_fetch? f      opoo "Formula reports different #{e.hash_type}: #{e.expected}"    end    private +  def retry_fetch? f +    @failed ||= {} +    already_failed = @failed.fetch(f.name, false) + +    if already_failed || !ARGV.include?("--retry") +      Homebrew.failed = true +      return false +    end + +    f.clear_cache +    @failed[f.name] = true +    true +  end +    def fetch_fetchable f      f.clear_cache if ARGV.force? | 
