Raise an exception if an invalid tar file is added.

This commit is contained in:
Mitchell Hashimoto 2012-07-01 21:52:18 -07:00
parent a35f6a175d
commit e7bed7c2ff
2 changed files with 10 additions and 1 deletions

View File

@ -26,6 +26,7 @@ module Vagrant
# * BoxAlreadyExists - The box you're attempting to add already exists.
# * BoxProviderDoesntMatch - If the given box provider doesn't match the
# actual box provider in the untarred box.
# * BoxUnpackageFailure - An invalid tar file.
# * BoxUpgradeRequired - You're attempting to add a box when there is a
# V1 box with the same name that must first be upgraded.
#
@ -53,7 +54,11 @@ module Vagrant
# Change directory to the box directory and unpackage the tar
Dir.chdir(box_dir) do
@logger.debug("Unpacking box file into box directory...")
Archive::Tar::Minitar.unpack(path.to_s, box_dir.to_s)
begin
Archive::Tar::Minitar.unpack(path.to_s, box_dir.to_s)
rescue SystemCallError
raise Errors::BoxUnpackageFailure
end
end
# Find the box we just added

View File

@ -65,6 +65,10 @@ describe Vagrant::BoxCollection2 do
# Verify the box doesn't exist
instance.find(box_name, bad_provider).should be_nil
end
it "should raise an exception if you add an invalid box file" do
pending "I don't know how to generate an invalid tar."
end
end
describe "listing all" do