diff --git a/lib/vagrant/actions/box/download.rb b/lib/vagrant/actions/box/download.rb index ae2ba1f0c..9d12e713f 100644 --- a/lib/vagrant/actions/box/download.rb +++ b/lib/vagrant/actions/box/download.rb @@ -18,7 +18,7 @@ module Vagrant [Downloaders::HTTP, Downloaders::File].each do |dler| if dler.match?(@runner.uri) logger.info "Downloading via #{dler}..." - @downloader = dler.new + @downloader = dler.new(@runner.env) end end @@ -52,7 +52,7 @@ module Vagrant yield tempfile end end - + def file_options # create, write only, fail if the file exists, binary if windows File::WRONLY|File::EXCL|File::CREAT|(Mario::Platform.windows? ? File::BINARY : 0) diff --git a/lib/vagrant/actions/vm/export.rb b/lib/vagrant/actions/vm/export.rb index a967346f5..7993dc285 100644 --- a/lib/vagrant/actions/vm/export.rb +++ b/lib/vagrant/actions/vm/export.rb @@ -2,8 +2,6 @@ module Vagrant module Actions module VM class Export < Base - include Util::ProgressMeter - attr_reader :temp_dir def execute! @@ -36,10 +34,10 @@ module Vagrant def export logger.info "Exporting VM to #{ovf_path}..." @runner.vm.export(ovf_path) do |progress| - update_progress(progress.percent, 100, false) + logger.report_progress(progress.percent, 100, false) end - complete_progress + logger.clear_progress end end end diff --git a/lib/vagrant/actions/vm/import.rb b/lib/vagrant/actions/vm/import.rb index 49f2e98d6..4a545c152 100644 --- a/lib/vagrant/actions/vm/import.rb +++ b/lib/vagrant/actions/vm/import.rb @@ -2,18 +2,16 @@ module Vagrant module Actions module VM class Import < Base - include Util::ProgressMeter - def execute! @runner.invoke_around_callback(:import) do Busy.busy do logger.info "Importing base VM (#{@runner.env.box.ovf_file})..." # Use the first argument passed to the action @runner.vm = VirtualBox::VM.import(@runner.env.box.ovf_file) do |progress| - update_progress(progress.percent, 100, false) + logger.report_progress(progress.percent, 100, false) end - complete_progress + logger.clear_progress raise ActionException.new(:virtualbox_import_failure) unless @runner.vm end diff --git a/lib/vagrant/downloaders/base.rb b/lib/vagrant/downloaders/base.rb index 320a1a3df..07b08754b 100644 --- a/lib/vagrant/downloaders/base.rb +++ b/lib/vagrant/downloaders/base.rb @@ -5,6 +5,13 @@ module Vagrant class Base include Vagrant::Util + # The environment which this downloader is operating. + attr_reader :env + + def initialize(env) + @env = env + end + # Called prior to execution so any error checks can be done def prepare(source_url); end @@ -13,4 +20,4 @@ module Vagrant def download!(source_url, destination_file); end end end -end \ No newline at end of file +end diff --git a/lib/vagrant/downloaders/http.rb b/lib/vagrant/downloaders/http.rb index b999c0c22..f4a4bab21 100644 --- a/lib/vagrant/downloaders/http.rb +++ b/lib/vagrant/downloaders/http.rb @@ -3,8 +3,6 @@ module Vagrant # Downloads a file from an HTTP URL to a temporary file. This # downloader reports its progress to stdout while downloading. class HTTP < Base - include Util::ProgressMeter - def self.match?(uri) # URI.parse barfs on ':\\files \on\ windows' # TODO temprorary @@ -26,7 +24,7 @@ module Vagrant # Progress reporting is limited to every 25 segments just so # we're not constantly updating if segment_count % 25 == 0 - update_progress(progress, total) + env.logger.report_progress(progress, total) segment_count = 0 end @@ -35,7 +33,7 @@ module Vagrant end end - complete_progress + env.logger.clear_progress end end end diff --git a/test/test_helper.rb b/test/test_helper.rb index b39fa3736..60f6516a0 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -142,7 +142,7 @@ class Test::Unit::TestCase tempfile = mock("tempfile") tempfile.stubs(:write) - [downloader_klass.new, tempfile] + [downloader_klass.new(mock_environment), tempfile] end end diff --git a/test/vagrant/downloaders/base_test.rb b/test/vagrant/downloaders/base_test.rb index 6c65720d2..78006cc2f 100644 --- a/test/vagrant/downloaders/base_test.rb +++ b/test/vagrant/downloaders/base_test.rb @@ -7,7 +7,8 @@ class BaseDownloaderTest < Test::Unit::TestCase context "base instance" do setup do - @base = Vagrant::Downloaders::Base.new + @env = mock_environment + @base = Vagrant::Downloaders::Base.new(@env) end should "implement prepare which does nothing" do