Refactor fetch
Remove direct references to checksum types, access them through the Checksum::TYPES constant instead.
This commit is contained in:
parent
c166ce3f58
commit
67d798e905
@ -19,24 +19,26 @@ module Homebrew extend self
|
|||||||
end
|
end
|
||||||
|
|
||||||
puts "Fetching: #{bucket * ', '}" if bucket.size > 1
|
puts "Fetching: #{bucket * ', '}" if bucket.size > 1
|
||||||
|
bucket.each { |f| fetch_formula(f) }
|
||||||
|
end
|
||||||
|
|
||||||
bucket.each do |f|
|
def already_fetched? f
|
||||||
already_downloaded = f.cached_download.exist?
|
f.cached_download.exist?
|
||||||
f.cached_download.rmtree if already_downloaded and ARGV.force?
|
end
|
||||||
|
|
||||||
the_tarball, _ = f.fetch
|
def fetch_formula f
|
||||||
next unless the_tarball.kind_of? Pathname
|
f.cached_download.rmtree if already_fetched?(f) && ARGV.force?
|
||||||
|
tarball, _ = f.fetch
|
||||||
|
|
||||||
puts "Downloaded to: #{the_tarball}" unless already_downloaded
|
# FIXME why are strategies returning different types?
|
||||||
puts "SHA1: #{the_tarball.sha1}"
|
return unless tarball.is_a? Pathname
|
||||||
puts "SHA256: #{the_tarball.sha2}"
|
|
||||||
|
|
||||||
begin
|
puts "Downloaded to: #{tarball}" unless already_fetched?(f)
|
||||||
f.verify_download_integrity the_tarball
|
puts Checksum::TYPES.map { |t| "#{t.to_s.upcase}: #{tarball.send(t)}" }
|
||||||
rescue ChecksumMismatchError => e
|
|
||||||
Homebrew.failed = true
|
f.verify_download_integrity(tarball)
|
||||||
opoo "Formula reports different #{e.hash_type}: #{e.expected}"
|
rescue ChecksumMismatchError => e
|
||||||
end
|
Homebrew.failed = true
|
||||||
end
|
opoo "Formula reports different #{e.hash_type}: #{e.expected}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user