Class: CurlApacheMirrorDownloadStrategy

Inherits:
CurlDownloadStrategy show all
Defined in:
Library/Homebrew/download_strategy.rb

Overview

Detect and download from Apache Mirror

Instance Attribute Summary

Attributes inherited from CurlDownloadStrategy

#mirrors, #tarball_path, #temporary_path

Attributes inherited from AbstractDownloadStrategy

#cached_location, #meta, #name, #resource, #shutup, #version

Instance Method Summary collapse

Methods inherited from CurlDownloadStrategy

#cached_location, #clear_cache, #fetch, #initialize

Methods inherited from AbstractFileDownloadStrategy

#stage

Methods inherited from AbstractDownloadStrategy

#clear_cache, #expand_safe_system_args, #fetch, #initialize, #ohai, #puts, #quiet_safe_system, #safe_system, #shutup!, #source_modified_time, #stage

Methods included from FileUtils

#make, mkdir, mktemp, #old_mkdir, #old_ruby, #ruby, #scons, #xcodebuild

Constructor Details

This class inherits a constructor from CurlDownloadStrategy

Instance Method Details

#_fetchObject



408
409
410
411
412
413
414
415
416
417
418
419
420
421
# File 'Library/Homebrew/download_strategy.rb', line 408

def _fetch
  return super if @tried_apache_mirror
  @tried_apache_mirror = true

  mirrors = apache_mirrors
  path_info = mirrors.fetch("path_info")
  @url = mirrors.fetch("preferred") + path_info
  @mirrors |= %W[https://archive.apache.org/dist/#{path_info}]

  ohai "Best Mirror #{@url}"
  super
rescue IndexError, JSON::ParserError
  raise CurlDownloadStrategyError, "Couldn't determine mirror, try again later."
end

#apache_mirrorsObject



400
401
402
403
404
405
406
# File 'Library/Homebrew/download_strategy.rb', line 400

def apache_mirrors
  mirrors, = Open3.capture3(
    *curl_args(*_curl_opts, "--silent", "--location", "#{@url}&asjson=1"),
  )

  JSON.parse(mirrors)
end