Only check for box directory if it is set during unpackage recovery [related to GH-170]

This commit is contained in:
Mitchell Hashimoto 2010-10-01 09:20:18 -07:00
parent 11e775b03b
commit 61314c5e21
2 changed files with 8 additions and 1 deletions

View File

@ -31,7 +31,7 @@ module Vagrant
end
def recover(env)
if File.directory?(box_directory)
if box_directory && File.directory?(box_directory)
FileUtils.rm_rf(box_directory)
end
end

View File

@ -26,6 +26,13 @@ class UnpackageBoxActionTest < Test::Unit::TestCase
FileUtils.stubs(:rm_rf)
end
should "do nothing if box directory is not set" do
@instance.stubs(:box_directory).returns(nil)
File.expects(:directory?).never
FileUtils.expects(:rm_rf).never
@instance.recover(nil)
end
should "do nothing if not a directory" do
FileUtils.expects(:rm_rf).never
@instance.recover(nil)