Skip to content
Snippets Groups Projects
Commit 67d798e9 authored by Jack Nagel's avatar Jack Nagel
Browse files

Refactor fetch

Remove direct references to checksum types, access them through the
Checksum::TYPES constant instead.
parent c166ce3f
No related branches found
No related tags found
No related merge requests found
......@@ -19,24 +19,26 @@ module Homebrew extend self
end
puts "Fetching: #{bucket * ', '}" if bucket.size > 1
bucket.each { |f| fetch_formula(f) }
end
bucket.each do |f|
already_downloaded = f.cached_download.exist?
f.cached_download.rmtree if already_downloaded and ARGV.force?
def already_fetched? f
f.cached_download.exist?
end
the_tarball, _ = f.fetch
next unless the_tarball.kind_of? Pathname
def fetch_formula f
f.cached_download.rmtree if already_fetched?(f) && ARGV.force?
tarball, _ = f.fetch
puts "Downloaded to: #{the_tarball}" unless already_downloaded
puts "SHA1: #{the_tarball.sha1}"
puts "SHA256: #{the_tarball.sha2}"
# FIXME why are strategies returning different types?
return unless tarball.is_a? Pathname
begin
f.verify_download_integrity the_tarball
rescue ChecksumMismatchError => e
Homebrew.failed = true
opoo "Formula reports different #{e.hash_type}: #{e.expected}"
end
end
puts "Downloaded to: #{tarball}" unless already_fetched?(f)
puts Checksum::TYPES.map { |t| "#{t.to_s.upcase}: #{tarball.send(t)}" }
f.verify_download_integrity(tarball)
rescue ChecksumMismatchError => e
Homebrew.failed = true
opoo "Formula reports different #{e.hash_type}: #{e.expected}"
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment