Skip to content

Instantly share code, notes, and snippets.

@colindean
Created March 16, 2017 23:24
Show Gist options
  • Save colindean/ff1a08342f61213195ef862b0ce917fb to your computer and use it in GitHub Desktop.
Save colindean/ff1a08342f61213195ef862b0ce917fb to your computer and use it in GitHub Desktop.
Slowly working on adding Aria2 support to Homebrew Cask
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