From 05c6379abb7bb1d8f4225ceabe74596bb899f6f0 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 17 Mar 2013 11:41:34 -0700 Subject: [PATCH] Setup file protocol if adding a box from a file --- lib/vagrant/action/builtin/box_add.rb | 8 +++++++- lib/vagrant/util/downloader.rb | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/action/builtin/box_add.rb b/lib/vagrant/action/builtin/box_add.rb index 06ee41482..4576b9731 100644 --- a/lib/vagrant/action/builtin/box_add.rb +++ b/lib/vagrant/action/builtin/box_add.rb @@ -18,12 +18,18 @@ module Vagrant @temp_path = env[:tmp_path].join("box" + Time.now.to_i.to_s) @logger.info("Downloading box to: #{@temp_path}") + url = env[:box_url] + if url !~ /^[a-z0-9]+:.*$/i + @logger.info("No protocol found on box URL, assuming file:") + url = "file:#{url}" + end + # Download the box to a temporary path. We store the temporary # path as an instance variable so that the `#recover` method can # access it. env[:ui].info(I18n.t("vagrant.actions.box.download.downloading")) begin - downloader = Util::Downloader.new(env[:box_url], @temp_path, :ui => env[:ui]) + downloader = Util::Downloader.new(url, @temp_path, :ui => env[:ui]) downloader.download! rescue Errors::DownloaderInterrupted # The downloader was interrupted, so just return, because that diff --git a/lib/vagrant/util/downloader.rb b/lib/vagrant/util/downloader.rb index 8f39b9a56..50790cb9c 100644 --- a/lib/vagrant/util/downloader.rb +++ b/lib/vagrant/util/downloader.rb @@ -96,6 +96,10 @@ module Vagrant # If the download was interrupted, then raise a specific error raise Errors::DownloaderInterrupted if interrupted + # If we're outputting to the UI, clear the output to + # avoid lingering progress meters. + @ui.clear_line if @ui + # If it didn't exit successfully, we need to parse the data and # show an error message. if result.exit_code != 0