Module: Imagemaster3000::Verification::Hash

Defined in:
lib/imagemaster3000/verification/hash.rb

Instance Method Summary collapse

Instance Method Details

#verify_hash!Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/imagemaster3000/verification/hash.rb', line 4

def verify_hash!
  logger.debug 'Verifying checksum'
  computed_checksum = verification[:hash][:function].file(local_filename).hexdigest
  if checksum_present? computed_checksum
    verification[:hash][:checksum] = ::Digest::SHA512.file(local_filename).hexdigest
    return
  end

  raise Imagemaster3000::Errors::VerificationError,
        "Not exactly one checksum found for file #{local_filename}: expected: #{computed_checksum}"
end