Extract checksum type function

This commit is contained in:
Adam Vandenberg 2011-12-17 17:01:21 -08:00
parent f052bcbd62
commit fd082f63b6

View File

@ -588,13 +588,18 @@ private
return fetched, downloader
end
# Detect which type of checksum is being used, or nil if none
def checksum_type
CHECKSUM_TYPES.detect { |type| instance_variable_defined?("@#{type}") }
end
# For FormulaInstaller.
def verify_download_integrity fn, *args
require 'digest'
if args.length != 2
type=CHECKSUM_TYPES.detect { |type| instance_variable_defined?("@#{type}") }
type ||= :md5
type = checksum_type || :md5
supplied = instance_variable_get("@#{type}")
# Convert symbol to readable string
type = type.to_s.upcase
else
supplied, type = args