diff --git a/Library/Homebrew/cask/download.rb b/Library/Homebrew/cask/download.rb index d2719fb9cf..baec2eb63f 100644 --- a/Library/Homebrew/cask/download.rb +++ b/Library/Homebrew/cask/download.rb @@ -82,8 +82,7 @@ module Cask sig { override.params(filename: Pathname).void } def verify_download_integrity(filename) - official_cask_tap = @cask.tap&.official? - if @cask.sha256 == :no_check && !official_cask_tap + if no_checksum_defined? && !official_cask_tap? opoo "No checksum defined for cask '#{@cask}', skipping verification." return end @@ -114,6 +113,24 @@ module Cask end end + sig { returns(T::Boolean) } + def official_cask_tap? + tap = @cask.tap + return false if tap.blank? + + tap.official? + end + + sig { returns(T::Boolean) } + def no_checksum_defined? + @cask.sha256 == :no_check + end + + sig { override.returns(T::Boolean) } + def silence_checksum_missing_error? + no_checksum_defined? && official_cask_tap? + end + sig { override.returns(T.nilable(::URL)) } def determine_url url diff --git a/Library/Homebrew/downloadable.rb b/Library/Homebrew/downloadable.rb index 037e9ad0d6..f8fcaf8355 100644 --- a/Library/Homebrew/downloadable.rb +++ b/Library/Homebrew/downloadable.rb @@ -117,6 +117,8 @@ module Downloadable filename.verify_checksum(checksum) end rescue ChecksumMissingError + return if silence_checksum_missing_error? + opoo <<~EOS Cannot verify integrity of '#{filename.basename}'. No checksum was provided. @@ -132,6 +134,11 @@ module Downloadable private + sig { overridable.returns(T::Boolean) } + def silence_checksum_missing_error? + false + end + sig { overridable.returns(T.nilable(URL)) } def determine_url @url