core: clean up Bundler tempfiles [GH-4103]

This commit is contained in:
Mitchell Hashimoto 2014-08-08 16:47:37 -07:00
parent 15f1823d5c
commit 04835ae612
4 changed files with 14 additions and 0 deletions

View File

@ -27,6 +27,7 @@ BUG FIXES:
but this fixes a few. [GH-4159]
- core: Fix crash case when destroying with an invalid provisioner. [GH-4281]
- core: Box names with colons work on Windows. [GH-4100]
- core: Cleanup all temp files. [GH-4103]
- commands/package: base package won't crash with exception [GH-4017]
- commands/rsync-auto: Destroyed machines won't raise exceptions. [GH-4031]
- communicators/ssh: Nicer error if remote unexpectedly disconects. [GH-4038]

View File

@ -103,9 +103,13 @@ env = nil
begin
require 'log4r'
require 'vagrant'
require 'vagrant/bundler'
require 'vagrant/cli'
require 'vagrant/util/platform'
# Schedule the cleanup of things
at_exit(&Vagrant::Bundler.instance.method(:deinit))
# Create a logger right away
logger = Log4r::Logger.new("vagrant::bin::vagrant")
logger.info("`vagrant` invoked: #{ARGV.inspect}")

View File

@ -77,6 +77,13 @@ module Vagrant
Gem.clear_paths
end
# Removes any temporary files created by init
def deinit
File.unlink(ENV["BUNDLE_APP_CONFIG"]) rescue nil
File.unlink(ENV["BUNDLE_CONFIG"]) rescue nil
File.unlink(ENV["GEMFILE"]) rescue nil
end
# Installs the list of plugins.
#
# @param [Hash] plugins

View File

@ -53,6 +53,8 @@ module Vagrant
Vagrant::Util::Downloader.new(url, tf.path).download!
data = JSON.parse(File.read(tf.path))
data["version"]
ensure
tf.unlink if tf
end
# This returns whether or not 3rd party plugins should be loaded.