Module: Cask::Verify

Defined in:
brew/Library/Homebrew/cask/verify.rb

Class Method Summary collapse

Class Method Details

.all(cask, downloaded_path) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'brew/Library/Homebrew/cask/verify.rb', line 7

def all(cask, downloaded_path)
  if cask.sha256 == :no_check
    ohai "No SHA-256 checksum defined for Cask '#{cask}', skipping verification."
    return
  end

  ohai "Verifying SHA-256 checksum for Cask '#{cask}'."

  expected = cask.sha256
  computed = downloaded_path.sha256

  raise CaskSha256MissingError.new(cask.token, expected, computed) if expected.nil? || expected.empty?

  return if expected == computed

  ohai "Note: Running `brew update` may fix SHA-256 checksum errors."
  raise CaskSha256MismatchError.new(cask.token, expected, computed, downloaded_path)
end