BoxCollection#find should only find V1 box when searching for vbox
This commit is contained in:
parent
e2dd0b0cf2
commit
0ec639c8e1
|
@ -198,18 +198,22 @@ module Vagrant
|
|||
return Box.new(name, provider, box_directory.dirname)
|
||||
end
|
||||
|
||||
# Check if a V1 version of this box exists, and if so, raise an
|
||||
# exception notifying the caller that the box exists but needs
|
||||
# to be upgraded. We don't do the upgrade here because it can be
|
||||
# a fairly intensive activity and don't want to immediately degrade
|
||||
# user performance on a find.
|
||||
#
|
||||
# To determine if it is a V1 box we just do a simple heuristic
|
||||
# based approach.
|
||||
@logger.info("Searching for V1 box: #{name}")
|
||||
if v1_box?(@directory.join(name))
|
||||
@logger.warn("V1 box found: #{name}")
|
||||
raise Errors::BoxUpgradeRequired, :name => name
|
||||
# If we're looking for a VirtualBox box, then we check if there is
|
||||
# a V1 box.
|
||||
if provider == :virtualbox
|
||||
# Check if a V1 version of this box exists, and if so, raise an
|
||||
# exception notifying the caller that the box exists but needs
|
||||
# to be upgraded. We don't do the upgrade here because it can be
|
||||
# a fairly intensive activity and don't want to immediately degrade
|
||||
# user performance on a find.
|
||||
#
|
||||
# To determine if it is a V1 box we just do a simple heuristic
|
||||
# based approach.
|
||||
@logger.info("Searching for V1 box: #{name}")
|
||||
if v1_box?(@directory.join(name))
|
||||
@logger.warn("V1 box found: #{name}")
|
||||
raise Errors::BoxUpgradeRequired, :name => name
|
||||
end
|
||||
end
|
||||
|
||||
# Didn't find it, return nil
|
||||
|
|
|
@ -168,6 +168,14 @@ describe Vagrant::BoxCollection do
|
|||
expect { instance.find("foo", :virtualbox) }.
|
||||
to raise_error(Vagrant::Errors::BoxUpgradeRequired)
|
||||
end
|
||||
|
||||
it "should return nil if there is a V1 box but we're looking for another provider" do
|
||||
# Create a V1 box
|
||||
environment.box1("foo")
|
||||
|
||||
# Test
|
||||
instance.find("foo", :another_provider).should be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe "upgrading" do
|
||||
|
|
Loading…
Reference in New Issue