core: box add fails early if box already exists [GH-2621]
This commit is contained in:
parent
13c8235963
commit
d86efdb9be
|
@ -14,6 +14,7 @@ BUG FIXES:
|
|||
checking a box checksum. [GH-2716]
|
||||
- core: Better error message if your plugin state file becomes corrupt
|
||||
somehow. [GH-2694]
|
||||
- core: Box add will fail early if the box already exists. [GH-2621]
|
||||
- hosts/bsd: Only run `nfsd checkexports` if there is an exports file.
|
||||
[GH-2714]
|
||||
- commands/plugin: Fix exception that could happen rarely when installing
|
||||
|
|
|
@ -20,7 +20,6 @@ module Vagrant
|
|||
@download_interrupted = false
|
||||
|
||||
box_name = env[:box_name]
|
||||
|
||||
box_formats = env[:box_provider]
|
||||
if box_formats
|
||||
# Determine the formats a box can support and allow the box to
|
||||
|
@ -32,6 +31,22 @@ module Vagrant
|
|||
end
|
||||
end
|
||||
|
||||
# Determine if we already have the box before downloading
|
||||
# it again. We can only do this if we specify a format
|
||||
if box_formats
|
||||
begin
|
||||
if env[:box_collection].find(box_name, box_formats)
|
||||
raise Errors::BoxAlreadyExists,
|
||||
:name => box_name,
|
||||
:formats => [box_formats].flatten.join(", ")
|
||||
end
|
||||
rescue Vagrant::Errors::BoxUpgradeRequired
|
||||
# If the box needs to be upgraded, do it.
|
||||
env[:box_collection].upgrade(box_name)
|
||||
retry
|
||||
end
|
||||
end
|
||||
|
||||
# Determine the checksum type to use
|
||||
checksum = (env[:box_checksum] || "").to_s
|
||||
checksum_klass = nil
|
||||
|
|
Loading…
Reference in New Issue