Created
March 16, 2017 23:24
-
-
Save colindean/ff1a08342f61213195ef862b0ce917fb to your computer and use it in GitHub Desktop.
Slowly working on adding Aria2 support to Homebrew Cask
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AriaDownloadStrategy < CurlDownloadStrategy | |
def aria_args(options = {}) | |
aria = Pathname.new ENV["HOMEBREW_ARIA"] | |
aria = Pathname.new "/usr/local/bin/aria2c" unless aria.exist? | |
raise "#{aria} is not executable" unless aria.exist? && aria.executable? | |
args = [ | |
aria.to_s, | |
"--remote-time", | |
"--location", | |
] | |
case options[:user_agent] | |
when :browser | |
args << "--user-agent" << HOMEBREW_USER_AGENT_FAKE_SAFARI | |
else | |
args << "--user-agent" << HOMEBREW_USER_AGENT_CURL | |
end | |
unless options[:show_output] | |
args << "--progress-bar" unless ARGV.verbose? | |
args << "--verbose" if ENV["HOMEBREW_CURL_VERBOSE"] | |
args << "--fail" | |
args << "--silent" if !$stdout.tty? || ENV["TRAVIS"] | |
end | |
args << "--max-connection-per-server=#{ENV['HOMEBREW_ARIA_MAX_PER_SERVER']||8}" | |
args += options[:extra_args] if options[:extra_args] | |
args | |
end | |
def _fetch | |
odebug "Calling aria2c with args #{cask_curl_args.utf8_inspect}" | |
curl(*cask_aria_args) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment