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:
parent
27de1257e3
commit
7f45c63468
@ -28,19 +28,33 @@ module Homebrew extend self
|
|||||||
puts "Resource: #{r.name}"
|
puts "Resource: #{r.name}"
|
||||||
fetch_fetchable r
|
fetch_fetchable r
|
||||||
rescue ChecksumMismatchError => e
|
rescue ChecksumMismatchError => e
|
||||||
Homebrew.failed = true
|
retry if retry_fetch? f
|
||||||
opoo "Resource #{r.name} reports different #{e.hash_type}: #{e.expected}"
|
opoo "Resource #{r.name} reports different #{e.hash_type}: #{e.expected}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_formula f
|
def fetch_formula f
|
||||||
fetch_fetchable f
|
fetch_fetchable f
|
||||||
rescue ChecksumMismatchError => e
|
rescue ChecksumMismatchError => e
|
||||||
Homebrew.failed = true
|
retry if retry_fetch? f
|
||||||
opoo "Formula reports different #{e.hash_type}: #{e.expected}"
|
opoo "Formula reports different #{e.hash_type}: #{e.expected}"
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
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
|
def fetch_fetchable f
|
||||||
f.clear_cache if ARGV.force?
|
f.clear_cache if ARGV.force?
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user