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>
This commit is contained in:
Mike McQuaid 2014-03-01 12:28:45 +00:00
parent 27de1257e3
commit 7f45c63468

View File

@ -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?