mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
ApacheDownloadStrategy: fall back to specified mirrors
Fixes Homebrew/homebrew#24157.
This commit is contained in:
parent
4584407425
commit
ea32b5166c
@ -236,13 +236,16 @@ class CurlApacheMirrorDownloadStrategy < CurlDownloadStrategy
|
||||
end
|
||||
|
||||
def _fetch
|
||||
mirrors = Utils::JSON.load(apache_mirrors)
|
||||
url = mirrors.fetch('preferred') + mirrors.fetch('path_info')
|
||||
return super if @tried_apache_mirror
|
||||
@tried_apache_mirror = true
|
||||
|
||||
ohai "Best Mirror #{url}"
|
||||
curl url, '-C', downloaded_size, '-o', temporary_path
|
||||
mirrors = Utils::JSON.load(apache_mirrors)
|
||||
@url = mirrors.fetch('preferred') + mirrors.fetch('path_info')
|
||||
|
||||
ohai "Best Mirror #{@url}"
|
||||
super
|
||||
rescue IndexError, Utils::JSON::Error
|
||||
raise "Couldn't determine mirror. Try again later."
|
||||
raise CurlDownloadStrategyError, "Couldn't determine mirror, try again later."
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user