diff options
| author | Jack Nagel | 2013-01-11 18:03:51 -0600 |
|---|---|---|
| committer | Jack Nagel | 2013-02-01 22:17:46 -0600 |
| commit | 15ced99fd380da0016baa0505043660246ff7209 (patch) | |
| tree | aa1a31d5ad7aff71d1a5416ef50d4c59c6846cd8 /Library/Homebrew/cmd | |
| parent | 558f5cbdf4044e5d6288e3d6bd0fef730f8c5206 (diff) | |
| download | homebrew-15ced99fd380da0016baa0505043660246ff7209.tar.bz2 | |
Refactor fetch
Remove direct references to checksum types, access them through the
Checksum::TYPES constant instead.
Diffstat (limited to 'Library/Homebrew/cmd')
| -rw-r--r-- | Library/Homebrew/cmd/fetch.rb | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/Library/Homebrew/cmd/fetch.rb b/Library/Homebrew/cmd/fetch.rb index a3b8c5252..dd33c5c33 100644 --- a/Library/Homebrew/cmd/fetch.rb +++ b/Library/Homebrew/cmd/fetch.rb @@ -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 |
