core: make the BoxAdd UI look a bit better
This commit is contained in:
parent
acc57a3c18
commit
e38ce34e56
|
@ -61,13 +61,13 @@ module Vagrant
|
||||||
|
|
||||||
metadata = nil
|
metadata = nil
|
||||||
begin
|
begin
|
||||||
metadata_path = download(url, env)
|
metadata_path = download(url, env, ui: false)
|
||||||
|
|
||||||
File.open(metadata_path) do |f|
|
File.open(metadata_path) do |f|
|
||||||
metadata = BoxMetadata.new(f)
|
metadata = BoxMetadata.new(f)
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
metadata_path.delete if metadata_path.file?
|
metadata_path.delete if metadata_path && metadata_path.file?
|
||||||
end
|
end
|
||||||
|
|
||||||
metadata_version = metadata.version(
|
metadata_version = metadata.version(
|
||||||
|
@ -234,7 +234,9 @@ module Vagrant
|
||||||
# Returns the download options for the download.
|
# Returns the download options for the download.
|
||||||
#
|
#
|
||||||
# @return [Hash]
|
# @return [Hash]
|
||||||
def downloader(url, env)
|
def downloader(url, env, **opts)
|
||||||
|
opts[:ui] = true if !opts.has_key?(:ui)
|
||||||
|
|
||||||
temp_path = env[:tmp_path].join("box" + Digest::SHA1.hexdigest(url))
|
temp_path = env[:tmp_path].join("box" + Digest::SHA1.hexdigest(url))
|
||||||
@logger.info("Downloading box: #{url} => #{temp_path}")
|
@logger.info("Downloading box: #{url} => #{temp_path}")
|
||||||
|
|
||||||
|
@ -264,24 +266,28 @@ module Vagrant
|
||||||
downloader_options[:ca_cert] = env[:box_download_ca_cert]
|
downloader_options[:ca_cert] = env[:box_download_ca_cert]
|
||||||
downloader_options[:continue] = true
|
downloader_options[:continue] = true
|
||||||
downloader_options[:insecure] = env[:box_download_insecure]
|
downloader_options[:insecure] = env[:box_download_insecure]
|
||||||
downloader_options[:ui] = env[:ui]
|
|
||||||
downloader_options[:client_cert] = env[:box_client_cert]
|
downloader_options[:client_cert] = env[:box_client_cert]
|
||||||
|
downloader_options[:ui] = env[:ui] if opts[:ui]
|
||||||
|
|
||||||
Util::Downloader.new(url, temp_path, downloader_options)
|
Util::Downloader.new(url, temp_path, downloader_options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def download(url, env)
|
def download(url, env, **opts)
|
||||||
d = downloader(url, env)
|
opts[:ui] = true if !opts.has_key?(:ui)
|
||||||
|
|
||||||
|
d = downloader(url, env, **opts)
|
||||||
|
|
||||||
# Download the box to a temporary path. We store the temporary
|
# Download the box to a temporary path. We store the temporary
|
||||||
# path as an instance variable so that the `#recover` method can
|
# path as an instance variable so that the `#recover` method can
|
||||||
# access it.
|
# access it.
|
||||||
|
if opts[:ui]
|
||||||
env[:ui].info(I18n.t(
|
env[:ui].info(I18n.t(
|
||||||
"vagrant.actions.box.download.downloading",
|
"vagrant.actions.box.download.downloading",
|
||||||
url: url))
|
url: url))
|
||||||
if File.file?(d.destination)
|
if File.file?(d.destination)
|
||||||
env[:ui].info(I18n.t("vagrant.actions.box.download.resuming"))
|
env[:ui].info(I18n.t("vagrant.actions.box.download.resuming"))
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
d.download!
|
d.download!
|
||||||
|
@ -305,7 +311,7 @@ module Vagrant
|
||||||
# @param [String] url
|
# @param [String] url
|
||||||
# @return [Boolean] true if metadata
|
# @return [Boolean] true if metadata
|
||||||
def metadata_url?(url, env)
|
def metadata_url?(url, env)
|
||||||
d = downloader(url, env)
|
d = downloader(url, env, ui: false)
|
||||||
|
|
||||||
# If we're downloading a file, cURL just returns no
|
# If we're downloading a file, cURL just returns no
|
||||||
# content-type (makes sense), so we just test if it is JSON
|
# content-type (makes sense), so we just test if it is JSON
|
||||||
|
|
Loading…
Reference in New Issue