Setup file protocol if adding a box from a file

This commit is contained in:
Mitchell Hashimoto 2013-03-17 11:41:34 -07:00
parent 25f66cee51
commit 05c6379abb
2 changed files with 11 additions and 1 deletions

View File

@ -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

View File

@ -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