diff --git a/lib/cask/audit.rb b/lib/cask/audit.rb index 985e25abae02e..f8e67301a4561 100644 --- a/lib/cask/audit.rb +++ b/lib/cask/audit.rb @@ -32,7 +32,7 @@ def _check_required_fields def _check_checksums odebug "Auditing checksums" - return if cask.sums == 0 + return if cask.sums == :no_check add_error "could not find checksum or no_checksum" unless cask.sums.is_a?(Array) && cask.sums.length > 0 end diff --git a/lib/cask/download.rb b/lib/cask/download.rb index 82de1c61017f3..7afa0f7505811 100644 --- a/lib/cask/download.rb +++ b/lib/cask/download.rb @@ -20,7 +20,7 @@ def perform HOMEBREW_CACHE_CASKS.join(downloaded_path.basename) rescue end - _check_sums(downloaded_path, cask.sums) unless cask.sums === 0 + _check_sums(downloaded_path, cask.sums) unless cask.sums === :no_check downloaded_path end diff --git a/lib/cask/dsl.rb b/lib/cask/dsl.rb index 50901c558f3ec..0490b66dc5f99 100644 --- a/lib/cask/dsl.rb +++ b/lib/cask/dsl.rb @@ -116,26 +116,34 @@ def hash_name(hash_type) end def sha1(sha1=nil) - if @sums == 0 + if @sums == :no_check raise CaskInvalidError.new(self.title, "'no_checksum' stanza conflicts with 'sha1'") end - @sums ||= [] - @sums << Checksum.new(:sha1, sha1) unless sha1.nil? + if sha1 == :no_check + @sums = sha1 + else + @sums ||= [] + @sums << Checksum.new(:sha1, sha1) unless sha1.nil? + end end def sha256(sha2=nil) - if @sums == 0 + if @sums == :no_check raise CaskInvalidError.new(self.title, "'no_checksum' stanza conflicts with 'sha256'") end - @sums ||= [] - @sums << Checksum.new(:sha2, sha2) unless sha2.nil? + if sha2 == :no_check + @sums = sha2 + else + @sums ||= [] + @sums << Checksum.new(:sha2, sha2) unless sha2.nil? + end end def no_checksum unless @sums.nil? or @sums.empty? raise CaskInvalidError.new(self.title, "'no_checksum' stanza conflicts with '#{hash_name(@sums.first.hash_type)}'") end - @sums = 0 + @sums = :no_check end def method_missing(method, *args)