core: delete the temporary file if adding succeeds

This commit is contained in:
Mitchell Hashimoto 2014-01-23 13:13:26 -08:00
parent ee139eb79d
commit adbcc9f34e
1 changed files with 15 additions and 4 deletions

View File

@ -73,11 +73,22 @@ module Vagrant
provider: metadata_provider.name))
# Now we have a URL, we have to download this URL.
box = nil
begin
box_url = download(metadata_provider.url, env)
# Add the box!
box = env[:box_collection].add(
box_url, metadata.name, metadata_version.version)
ensure
# Make sure we delete the temporary file after we add it,
# unless we were interrupted, in which case we keep it around
# so we can resume the download later.
if !@download_interrupted
@logger.debug("Deleting temporary box: #{box_url}")
box_url.delete
end
end
env[:ui].success(I18n.t(
"vagrant.box_added",