From efaabea5c0b4b89691c5b1e151e9755a240d8ecf Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 7 Apr 2013 14:48:49 -0700 Subject: [PATCH] Use vagrant tmp directory for boxes [GH-1442] --- CHANGELOG.md | 2 ++ lib/vagrant/box_collection.rb | 9 ++++++--- lib/vagrant/environment.rb | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 989ea1efa..d94ea9821 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,8 @@ BUG FIXES: reporting dynamic progress. - When using `Builder` instances for hooks, the builders will be merged for the proper before/after chain. [GH-1555] + - Use the Vagrant temporary directory again for temporary files + since they can be quite large and were messing with tmpfs. [GH-1442] ## 1.1.6 (April 3, 2013) diff --git a/lib/vagrant/box_collection.rb b/lib/vagrant/box_collection.rb index 2e9db8c54..c467cbe32 100644 --- a/lib/vagrant/box_collection.rb +++ b/lib/vagrant/box_collection.rb @@ -39,8 +39,11 @@ module Vagrant # # @param [Pathname] directory The directory that contains the collection # of boxes. - def initialize(directory) + def initialize(directory, options=nil) + options ||= {} + @directory = directory + @temp_root = options[:temp_dir_root] @logger = Log4r::Logger.new("vagrant::box_collection") end @@ -299,7 +302,7 @@ module Vagrant def v1_upgrade(dir) @logger.debug("Upgrading box in directory: #{dir}") - temp_dir = Pathname.new(Dir.mktmpdir("vagrant-")) + temp_dir = Pathname.new(Dir.mktmpdir(TEMP_PREFIX, @temp_root)) @logger.debug("Temporary directory for upgrading: #{temp_dir}") # Move all the things into the temporary directory @@ -333,7 +336,7 @@ module Vagrant # @param [String] dir Path to a temporary directory # @return [Object] The result of whatever the yield is def with_temp_dir(dir=nil) - dir ||= Dir.mktmpdir("vagrant-") + dir ||= Dir.mktmpdir(TEMP_PREFIX, @temp_root) dir = Pathname.new(dir) yield dir diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index b031b7ee7..6a32c1696 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -223,7 +223,7 @@ module Vagrant # # @return [BoxCollection] def boxes - @_boxes ||= BoxCollection.new(boxes_path) + @_boxes ||= BoxCollection.new(boxes_path, temp_dir_root: tmp_path) end # This is the global config, comprised of loading configuration from