core: Assume box isn't metadata if > threshold [GH-3107]
This commit is contained in:
parent
d0cf22dd5f
commit
2a93b6c396
|
@ -6,6 +6,7 @@ BUG FIXES:
|
|||
- core: Rare EINVAL errors on box adding are gone. [GH-3094]
|
||||
- core: Upgrading the home directory for Vagrant 1.5 uses the Vagrant
|
||||
temp dir. [GH-3095]
|
||||
- core: Assume a box isn't metadata if it exceeds 20 MB. [GH-3107]
|
||||
|
||||
## 1.5.0 (March 10, 2014)
|
||||
|
||||
|
|
|
@ -14,6 +14,10 @@ module Vagrant
|
|||
# This middleware will download a remote box and add it to the
|
||||
# given box collection.
|
||||
class BoxAdd
|
||||
# This is the size in bytes that if a file exceeds, is considered
|
||||
# to NOT be metadata.
|
||||
METADATA_SIZE_LIMIT = 20971520
|
||||
|
||||
def initialize(app, env)
|
||||
@app = app
|
||||
@logger = Log4r::Logger.new("vagrant::action::builtin::box_add")
|
||||
|
@ -445,6 +449,12 @@ module Vagrant
|
|||
|
||||
begin
|
||||
File.open(url, "r") do |f|
|
||||
if f.size > METADATA_SIZE_LIMIT
|
||||
# Quit early, don't try to parse the JSON of gigabytes
|
||||
# of box files...
|
||||
return false
|
||||
end
|
||||
|
||||
BoxMetadata.new(f)
|
||||
end
|
||||
return true
|
||||
|
|
Loading…
Reference in New Issue