diff options
| author | Jack Nagel | 2013-01-23 17:56:28 -0600 |
|---|---|---|
| committer | Jack Nagel | 2013-01-23 18:01:06 -0600 |
| commit | 37476d7ccc1fbb93bb982163e1cafd072984f00a (patch) | |
| tree | 956366540e271a11bb83e5a7e2544897ee2a9d4b /Library/Homebrew | |
| parent | db50e5be3360db36c4dd3f43b4ce24c5e640b704 (diff) | |
| download | homebrew-37476d7ccc1fbb93bb982163e1cafd072984f00a.tar.bz2 | |
CurlApacheMirrorDownloadStrategy: fetch mirrors in JSON format
Closes #16457.
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index f9df839d1..e4b4a5181 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -148,19 +148,16 @@ end # Detect and download from Apache Mirror class CurlApacheMirrorDownloadStrategy < CurlDownloadStrategy def _fetch - # Fetch mirror list site require 'open-uri' - mirror_list = open(@url).read() + require 'vendor/multi_json' - # Parse out suggested mirror - # Yep, this is ghetto, grep the first <strong></strong> element content - mirror_url = mirror_list[/<strong>([^<]+)/, 1] + mirrors = MultiJson.decode(open("#{@url}&asjson=1").read) + url = mirrors.fetch('preferred') + mirrors.fetch('path_info') - raise "Couldn't determine mirror. Try again later." if mirror_url.nil? - - ohai "Best Mirror #{mirror_url}" - # Start download from that mirror - curl mirror_url, '-o', @tarball_path + ohai "Best Mirror #{url}" + curl url, '-o', @tarball_path + rescue IndexError + raise "Couldn't determine mirror. Try again later." end end |
