From 7fe19d3a11c7bdb09929b562aa03985b8b0c7d9c Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 30 Jan 2013 21:53:26 -0800 Subject: [PATCH] Use box directory as temporary directory to avoid cross-device [GH-1199] --- CHANGELOG.md | 2 ++ lib/vagrant/box_collection.rb | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29c44db98..3b3974ea0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,8 @@ IMPROVEMENTS / BUG FIXES: while downloading a box over HTTP. [GH-1090] - Human-friendly error is raised if there are permission issues when using SCP to upload files. [GH-924] + - Box adding doesn't use `/tmp` anymore which can avoid some cross-device + copy issues. [GH-1199] ## 1.0.6 (December 21, 2012) diff --git a/lib/vagrant/box_collection.rb b/lib/vagrant/box_collection.rb index 1cdd651ee..e73308302 100644 --- a/lib/vagrant/box_collection.rb +++ b/lib/vagrant/box_collection.rb @@ -10,6 +10,8 @@ module Vagrant # for accessing/finding individual boxes, adding new boxes, or deleting # boxes. class BoxCollection + TEMP_PREFIX = "vagrant-box-add-temp-" + # The directory where the boxes in this collection are stored. # # A box collection matches a very specific folder structure that Vagrant @@ -85,7 +87,7 @@ module Vagrant # Create a temporary directory since we're not sure at this point if # the box we're unpackaging already exists (if no provider was given) - Dir.mktmpdir(["vagrant-tmp-", provider.to_s]) do |temp_dir| + Dir.mktmpdir(TEMP_PREFIX, directory.to_s) do |temp_dir| temp_dir = Pathname.new(temp_dir) # Extract the box into a temporary directory. @@ -158,6 +160,10 @@ module Vagrant box_name = child.basename.to_s + # Ignore anything that matches the temporary prefix (crazy + # race condition might be possible) + next if box_name =~ /^#{TEMP_PREFIX}/ + # If this is a V1 box, we still return that name, but specify # that the box is a V1 box. if v1_box?(child)