diff options
author | Homu <homu@barosl.com> | 2016-10-09 09:04:22 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-10-09 09:04:22 +0900 |
commit | 3c4d7ed701562d4dbd12ee74957b9108768271eb (patch) | |
tree | 86b58bdbdef58f4d874657524bed60f2df88f59c | |
parent | c0f7f128a55ef3165da52b44f1b82fca80de3238 (diff) | |
parent | 817d279e10682e042d0fc43938cbd6ef91b9effa (diff) | |
download | bundler-3c4d7ed701562d4dbd12ee74957b9108768271eb.tar.gz |
Auto merge of #5064 - bundler:aa-debug-etag-mismatch, r=indirect
change checksum warning to debug print
This was super helpful when the server was continuously returning bad
checksums, but it’s a scary warning to see anytime we update the
versions file. And we’re going to need to update the versions file at
least twice a year, so it seems like a good idea to head off users
worrying about a message that is actually things working as intended.
-rw-r--r-- | lib/bundler/compact_index_client/updater.rb | 4 | ||||
-rw-r--r-- | lib/bundler/fetcher/compact_index.rb | 27 |
2 files changed, 17 insertions, 14 deletions
diff --git a/lib/bundler/compact_index_client/updater.rb b/lib/bundler/compact_index_client/updater.rb index 185ebc8678..b407c64039 100644 --- a/lib/bundler/compact_index_client/updater.rb +++ b/lib/bundler/compact_index_client/updater.rb @@ -30,7 +30,7 @@ module Bundler Dir.mktmpdir("bundler-compact-index-") do |local_temp_dir| local_temp_path = Pathname.new(local_temp_dir).join(local_path.basename) - # download new file if retrying + # first try to fetch any new bytes on the existing file if retrying.nil? && local_path.file? FileUtils.cp local_path, local_temp_path headers["If-None-Match"] = etag_for(local_temp_path) @@ -61,7 +61,7 @@ module Bundler return nil end - unless retrying.nil? + if retrying raise MisMatchedChecksumError.new(remote_path, response_etag, etag_for(local_temp_path)) end diff --git a/lib/bundler/fetcher/compact_index.rb b/lib/bundler/fetcher/compact_index.rb index 76f7bc3094..38105a3f8f 100644 --- a/lib/bundler/fetcher/compact_index.rb +++ b/lib/bundler/fetcher/compact_index.rb @@ -66,7 +66,7 @@ module Bundler # Read info file checksums out of /versions, so we can know if gems are up to date fetch_uri.scheme != "file" && compact_index_client.update_and_parse_checksums! rescue CompactIndexClient::Updater::MisMatchedChecksumError => e - Bundler.ui.warn(e.message) + Bundler.ui.debug(e.message) nil end compact_index_request :available? @@ -78,9 +78,9 @@ module Bundler private def compact_index_client - @compact_index_client ||= + @compact_index_client ||= begin SharedHelpers.filesystem_access(cache_path) do - CompactIndexClient.new(cache_path, compact_fetcher) + CompactIndexClient.new(cache_path, client_fetcher) end.tap do |client| client.in_parallel = lambda do |inputs, &blk| func = lambda {|object, _index| blk.call(object) } @@ -89,6 +89,7 @@ module Bundler inputs.map { worker.deq } end end + end end def bundle_worker(func = nil) @@ -105,15 +106,17 @@ module Bundler Bundler.user_cache.join("compact_index", remote.cache_slug) end - def compact_fetcher - lambda do |path, headers| - begin - downloader.fetch(fetch_uri + path, headers) - rescue NetworkDownError => e - raise unless Bundler.feature_flag.allow_offline_install? && headers["If-None-Match"] - Bundler.ui.warn "Using the cached data for the new index because of a network error: #{e}" - Net::HTTPNotModified.new(nil, nil, nil) - end + def client_fetcher + ClientFetcher.new(self, Bundler.ui) + end + + ClientFetcher = Struct.new(:fetcher, :ui) do + def call(path, headers) + fetcher.downloader.fetch(fetcher.fetch_uri + path, headers) + rescue NetworkDownError => e + raise unless Bundler.feature_flag.allow_offline_install? && headers["If-None-Match"] + ui.warn "Using the cached data for the new index because of a network error: #{e}" + Net::HTTPNotModified.new(nil, nil, nil) end end end |