From f261c0571fd0c33ff6ea36b68d8c4020500b97c6 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 9 Dec 2011 14:55:24 -0800 Subject: [PATCH] Modify box download action to work with new runnerx --- lib/vagrant/action/box/download.rb | 8 ++++---- lib/vagrant/downloaders/base.rb | 7 ++----- lib/vagrant/downloaders/file.rb | 2 +- lib/vagrant/downloaders/http.rb | 8 ++++---- lib/vagrant/environment.rb | 4 +++- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/vagrant/action/box/download.rb b/lib/vagrant/action/box/download.rb index 381490f55..a8e3aecdc 100644 --- a/lib/vagrant/action/box/download.rb +++ b/lib/vagrant/action/box/download.rb @@ -37,8 +37,8 @@ module Vagrant # Use the class if it matches the given URI or if this # is the last class... if classes.length == (i + 1) || klass.match?(@env["box_url"]) - @env.ui.info I18n.t("vagrant.actions.box.download.with", :class => klass.to_s) - @downloader = klass.new(@env) + @env[:ui].info I18n.t("vagrant.actions.box.download.with", :class => klass.to_s) + @downloader = klass.new(@env[:ui]) break end end @@ -60,7 +60,7 @@ module Vagrant def recover(env) if temp_path && File.exist?(temp_path) - env.ui.info I18n.t("vagrant.actions.box.download.cleaning") + env[:ui].info I18n.t("vagrant.actions.box.download.cleaning") File.unlink(temp_path) end end @@ -72,7 +72,7 @@ module Vagrant end def box_temp_path - @env.env.tmp_path.join(BASENAME + Time.now.to_i.to_s) + @env[:tmp_path].join(BASENAME + Time.now.to_i.to_s) end def download_to(f) diff --git a/lib/vagrant/downloaders/base.rb b/lib/vagrant/downloaders/base.rb index 07b08754b..a853fba42 100644 --- a/lib/vagrant/downloaders/base.rb +++ b/lib/vagrant/downloaders/base.rb @@ -5,11 +5,8 @@ module Vagrant class Base include Vagrant::Util - # The environment which this downloader is operating. - attr_reader :env - - def initialize(env) - @env = env + def initialize(ui) + @ui = ui end # Called prior to execution so any error checks can be done diff --git a/lib/vagrant/downloaders/file.rb b/lib/vagrant/downloaders/file.rb index e527dcec5..40ef2db0d 100644 --- a/lib/vagrant/downloaders/file.rb +++ b/lib/vagrant/downloaders/file.rb @@ -14,7 +14,7 @@ module Vagrant end def download!(source_url, destination_file) - env.ui.info I18n.t("vagrant.downloaders.file.download") + @ui.info I18n.t("vagrant.downloaders.file.download") FileUtils.cp(source_url, destination_file.path) end end diff --git a/lib/vagrant/downloaders/http.rb b/lib/vagrant/downloaders/http.rb index 6f0115feb..25fb19e4b 100644 --- a/lib/vagrant/downloaders/http.rb +++ b/lib/vagrant/downloaders/http.rb @@ -27,7 +27,7 @@ module Vagrant end http.start do |h| - env.ui.info I18n.t("vagrant.downloaders.http.download", :url => source_url) + @ui.info I18n.t("vagrant.downloaders.http.download", :url => source_url) headers = nil if uri.user && uri.password @@ -56,8 +56,8 @@ module Vagrant # Progress reporting is limited to every 25 segments just so # we're not constantly updating if segment_count % 25 == 0 - env.ui.clear_line - env.ui.report_progress(progress, total) + @ui.clear_line + @ui.report_progress(progress, total) segment_count = 0 end @@ -66,7 +66,7 @@ module Vagrant end # Clear the line one last time so that the progress meter disappears - env.ui.clear_line + @ui.clear_line end end rescue SocketError diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index ae23a4644..c0101c501 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -209,7 +209,9 @@ module Vagrant # # @return [Action::Runner] def action_runner - @action_runner ||= Action::Runner.new(action_registry, :ui => @ui) + @action_runner ||= Action::Runner.new(action_registry, + :tmp_path => tmp_path, + :ui => @ui) end # Action registry for registering new actions with this environment.