Modify box download action to work with new runnerx

This commit is contained in:
Mitchell Hashimoto 2011-12-09 14:55:24 -08:00
parent 3c8261f4ac
commit f261c0571f
5 changed files with 14 additions and 15 deletions

View File

@ -37,8 +37,8 @@ module Vagrant
# Use the class if it matches the given URI or if this # Use the class if it matches the given URI or if this
# is the last class... # is the last class...
if classes.length == (i + 1) || klass.match?(@env["box_url"]) if classes.length == (i + 1) || klass.match?(@env["box_url"])
@env.ui.info I18n.t("vagrant.actions.box.download.with", :class => klass.to_s) @env[:ui].info I18n.t("vagrant.actions.box.download.with", :class => klass.to_s)
@downloader = klass.new(@env) @downloader = klass.new(@env[:ui])
break break
end end
end end
@ -60,7 +60,7 @@ module Vagrant
def recover(env) def recover(env)
if temp_path && File.exist?(temp_path) 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) File.unlink(temp_path)
end end
end end
@ -72,7 +72,7 @@ module Vagrant
end end
def box_temp_path 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 end
def download_to(f) def download_to(f)

View File

@ -5,11 +5,8 @@ module Vagrant
class Base class Base
include Vagrant::Util include Vagrant::Util
# The environment which this downloader is operating. def initialize(ui)
attr_reader :env @ui = ui
def initialize(env)
@env = env
end end
# Called prior to execution so any error checks can be done # Called prior to execution so any error checks can be done

View File

@ -14,7 +14,7 @@ module Vagrant
end end
def download!(source_url, destination_file) 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) FileUtils.cp(source_url, destination_file.path)
end end
end end

View File

@ -27,7 +27,7 @@ module Vagrant
end end
http.start do |h| 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 headers = nil
if uri.user && uri.password if uri.user && uri.password
@ -56,8 +56,8 @@ module Vagrant
# Progress reporting is limited to every 25 segments just so # Progress reporting is limited to every 25 segments just so
# we're not constantly updating # we're not constantly updating
if segment_count % 25 == 0 if segment_count % 25 == 0
env.ui.clear_line @ui.clear_line
env.ui.report_progress(progress, total) @ui.report_progress(progress, total)
segment_count = 0 segment_count = 0
end end
@ -66,7 +66,7 @@ module Vagrant
end end
# Clear the line one last time so that the progress meter disappears # Clear the line one last time so that the progress meter disappears
env.ui.clear_line @ui.clear_line
end end
end end
rescue SocketError rescue SocketError

View File

@ -209,7 +209,9 @@ module Vagrant
# #
# @return [Action::Runner] # @return [Action::Runner]
def 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 end
# Action registry for registering new actions with this environment. # Action registry for registering new actions with this environment.