Raise an exception if an invalid tar file is added.
This commit is contained in:
parent
a35f6a175d
commit
e7bed7c2ff
|
@ -26,6 +26,7 @@ module Vagrant
|
||||||
# * BoxAlreadyExists - The box you're attempting to add already exists.
|
# * BoxAlreadyExists - The box you're attempting to add already exists.
|
||||||
# * BoxProviderDoesntMatch - If the given box provider doesn't match the
|
# * BoxProviderDoesntMatch - If the given box provider doesn't match the
|
||||||
# actual box provider in the untarred box.
|
# actual box provider in the untarred box.
|
||||||
|
# * BoxUnpackageFailure - An invalid tar file.
|
||||||
# * BoxUpgradeRequired - You're attempting to add a box when there is a
|
# * BoxUpgradeRequired - You're attempting to add a box when there is a
|
||||||
# V1 box with the same name that must first be upgraded.
|
# 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
|
# Change directory to the box directory and unpackage the tar
|
||||||
Dir.chdir(box_dir) do
|
Dir.chdir(box_dir) do
|
||||||
@logger.debug("Unpacking box file into box directory...")
|
@logger.debug("Unpacking box file into box directory...")
|
||||||
|
begin
|
||||||
Archive::Tar::Minitar.unpack(path.to_s, box_dir.to_s)
|
Archive::Tar::Minitar.unpack(path.to_s, box_dir.to_s)
|
||||||
|
rescue SystemCallError
|
||||||
|
raise Errors::BoxUnpackageFailure
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Find the box we just added
|
# Find the box we just added
|
||||||
|
|
|
@ -65,6 +65,10 @@ describe Vagrant::BoxCollection2 do
|
||||||
# Verify the box doesn't exist
|
# Verify the box doesn't exist
|
||||||
instance.find(box_name, bad_provider).should be_nil
|
instance.find(box_name, bad_provider).should be_nil
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe "listing all" do
|
describe "listing all" do
|
||||||
|
|
Loading…
Reference in New Issue