summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-08-29 14:31:32 -0500
committerSamuel Giddins <segiddins@segiddins.me>2016-09-06 12:05:01 -0400
commit980495a414696864275d029a8d9be91fc30477ab (patch)
treef5fa5b42c78b376f9aafa41f95e1d365bf45e453
parentece6829c46e4768aae13f970a54017c272bf974d (diff)
downloadbundler-seg-compact-index-debugging.tar.gz
Add debug logging to the compact index clientseg-compact-index-debugging
-rw-r--r--lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb29
1 files changed, 26 insertions, 3 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