Use box directory as temporary directory to avoid cross-device [GH-1199]

This commit is contained in:
Mitchell Hashimoto 2013-01-30 21:53:26 -08:00
parent c164a5ca81
commit 7fe19d3a11
2 changed files with 9 additions and 1 deletions

View File

@ -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)

View File

@ -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)