summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-09-11 07:14:13 +0900
committerHomu <homu@barosl.com>2016-09-11 07:14:13 +0900
commit7607a611ed570edcad8c60a5f14192e20603e0e9 (patch)
tree851e8a7d0866fed57983a291a8bebeb4fa7ef479
parent3b5d04700aff686e0d119d4a7df329a19323f759 (diff)
parent980495a414696864275d029a8d9be91fc30477ab (diff)
downloadbundler-7607a611ed570edcad8c60a5f14192e20603e0e9.tar.gz
Auto merge of #4931 - bundler:seg-compact-index-debugging, r=indirect
Add debug logging to the compact index client \c @indirect
-rw-r--r--lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb29
-rw-r--r--lib/bundler/vendor/compact_index_client/lib/compact_index_client/updater.rb2
2 files changed, 27 insertions, 4 deletions
diff --git a/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb b/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb
index 9ab2722f18..c063c6b4dc 100644
--- a/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb
+++ b/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb
@@ -3,6 +3,12 @@ require "pathname"
require "set"
class Bundler::CompactIndexClient
+ DEBUG_MUTEX = Mutex.new
+ def self.debug
+ return unless ENV["DEBUG_COMPACT_INDEX"]
+ DEBUG_MUTEX.synchronize { warn("[#{self}] #{yield}") }
+ end
+
class Error < StandardError; end
require "bundler/vendor/compact_index_client/lib/compact_index_client/cache"
@@ -28,17 +34,20 @@ class Bundler::CompactIndexClient
end
def names
+ Bundler::CompactIndexClient.debug { "/names" }
update(@cache.names_path, "names")
@cache.names
end
def versions
+ Bundler::CompactIndexClient.debug { "/versions" }
update(@cache.versions_path, "versions")
versions, @info_checksums_by_name = @cache.versions
versions
end
def dependencies(names)
+ Bundler::CompactIndexClient.debug { "dependencies(#{names})" }
in_parallel.call(names) do |name|
update_info(name)
@cache.dependencies(name).map {|d| d.unshift(name) }
@@ -46,11 +55,13 @@ class Bundler::CompactIndexClient
end
def spec(name, version, platform = nil)
+ Bundler::CompactIndexClient.debug { "spec(name = #{name}, version = #{version}, platform = #{platform})" }
update_info(name)
@cache.specific_dependency(name, version, platform)
end
def update_and_parse_checksums!
+ Bundler::CompactIndexClient.debug { "update_and_parse_checksums!" }
return @info_checksums_by_name if @parsed_checksums
update(@cache.versions_path, "versions")
@info_checksums_by_name = @cache.checksums
@@ -60,15 +71,27 @@ class Bundler::CompactIndexClient
private
def update(local_path, remote_path)
- return unless @endpoints.add?(remote_path)
+ Bundler::CompactIndexClient.debug { "update(#{local_path}, #{remote_path})" }
+ unless @endpoints.add?(remote_path)
+ Bundler::CompactIndexClient.debug { "already fetched #{remote_path}" }
+ return
+ end
@updater.update(local_path, url(remote_path))
end
def update_info(name)
+ Bundler::CompactIndexClient.debug { "update_info(#{name})" }
path = @cache.info_path(name)
checksum = @updater.checksum_for_file(path)
- return unless existing = @info_checksums_by_name[name]
- return if checksum == existing
+ unless existing = @info_checksums_by_name[name]
+ Bundler::CompactIndexClient.debug { "skipping updating info for #{name} since it is missing from versions" }
+ return
+ end
+ if checksum == existing
+ Bundler::CompactIndexClient.debug { "skipping updating info for #{name} since the versions checksum matches the local checksum" }
+ return
+ end
+ Bundler::CompactIndexClient.debug { "updating info for #{name} since the versions checksum #{existing} != the local checksum #{checksum}" }
update(path, "info/#{name}")
end
diff --git a/lib/bundler/vendor/compact_index_client/lib/compact_index_client/updater.rb b/lib/bundler/vendor/compact_index_client/lib/compact_index_client/updater.rb
index 5c5ba41434..a410dd423c 100644
--- a/lib/bundler/vendor/compact_index_client/lib/compact_index_client/updater.rb
+++ b/lib/bundler/vendor/compact_index_client/lib/compact_index_client/updater.rb
@@ -50,7 +50,7 @@ class Bundler::CompactIndexClient
mode = response.is_a?(Net::HTTPPartialContent) ? "a" : "w"
local_temp_path.open(mode) {|f| f << content }
- response_etag = response["ETag"]
+ response_etag = response["ETag"].gsub(%r{\AW/}, "")
if etag_for(local_temp_path) == response_etag
FileUtils.mv(local_temp_path, local_path)
return