From 0a43cf2b6f31bafca500307fdf99edc7e0cff982 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 3 Dec 2013 18:52:44 -0800 Subject: [PATCH] core: fix exception when checksum type is nil Thanks @johnbellone --- lib/vagrant/action/builtin/box_add.rb | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/vagrant/action/builtin/box_add.rb b/lib/vagrant/action/builtin/box_add.rb index 330b8f633..657e4c025 100644 --- a/lib/vagrant/action/builtin/box_add.rb +++ b/lib/vagrant/action/builtin/box_add.rb @@ -21,18 +21,19 @@ module Vagrant # Determine the checksum type to use checksum = (env[:box_checksum] || "").to_s - checksum_klass = case env[:box_checksum_type].to_sym - when nil - nil - when :md5 - Digest::MD5 - when :sha1 - Digest::SHA1 - when :sha256 - Digest::SHA2 - else - raise Errors::BoxChecksumInvalidType, - type: env[:box_checksum_type].to_s + checksum_klass = nil + if env[:box_checksum_type] + checksum_klass = case env[:box_checksum_type].to_sym + when :md5 + Digest::MD5 + when :sha1 + Digest::SHA1 + when :sha256 + Digest::SHA2 + else + raise Errors::BoxChecksumInvalidType, + type: env[:box_checksum_type].to_s + end end # Go through each URL and attempt to download it