From 07878c957a285bf59e50fa4d0c4c353109bbc6ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Mon, 20 Oct 2014 12:45:40 +0200 Subject: [PATCH] [Command::Update] Support Axel for optimised downloading. --- lib/motion/command/update.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/motion/command/update.rb b/lib/motion/command/update.rb index 5b7a6aec..231fef2b 100644 --- a/lib/motion/command/update.rb +++ b/lib/motion/command/update.rb @@ -88,6 +88,16 @@ module Motion; class Command resp end + def download(url, dest) + if system("which axel > /dev/null") + unless system("axel -n 10 -a -o '#{dest}' '#{url}'") + die "Error when connecting to the server. Check your Internet connection and try again." + end + else + curl("-# '#{url}' -o '#{dest}'") + end + end + def perform_check update_check_file = File.join(ENV['TMPDIR'] || '/tmp', '.motion-update-check') if !File.exist?(update_check_file) or (Time.now - File.mtime(update_check_file) > 60 * 60 * 24) @@ -123,7 +133,7 @@ module Motion; class Command $stderr.puts 'Downloading software update...' url = resp tmp_dest = '/tmp/_rubymotion_su.pkg' - curl("-# \"#{url}\" -o #{tmp_dest}") + download(url, tmp_dest) if @wanted_software_version or @prerelease_mode FileUtils.mv '/Library/RubyMotion', '/Library/RubyMotion.old'