diff options
| author | Mike McQuaid | 2014-03-01 12:28:45 +0000 | 
|---|---|---|
| committer | Mike McQuaid | 2014-03-01 16:45:31 +0000 | 
| commit | 7f45c634681330ab32d9d069d6af131283695664 (patch) | |
| tree | 60aaa1dc7327ce6c3bc3fe4049631574758207da /Library/Homebrew/cmd/fetch.rb | |
| parent | 27de1257e3fb5d218b5829b4ed9293d05ebd27ac (diff) | |
| download | brew-7f45c634681330ab32d9d069d6af131283695664.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? | 
