Module: Cask::Verify Private

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

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Helper module for verifying a cask's checksum.

Class Method Summary collapse

Class Method Details

.all(cask, downloaded_path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'Library/Homebrew/cask/verify.rb', line 11

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