diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2016-11-28 12:31:27 -0600 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2016-11-28 12:31:27 -0600 |
commit | 1a960d35e78945fa41da006894d137680fb178cc (patch) | |
tree | 894739aee01d73c02ce4bc925f177919e7cda965 /lib/bundler/compact_index_client.rb | |
parent | c5efd85580d6a6d40442393f1f2d21c6db1306e1 (diff) | |
download | bundler-1a960d35e78945fa41da006894d137680fb178cc.tar.gz |
[CompactIndexClient] Synchronize access to the list of fetched endpoints
Diffstat (limited to 'lib/bundler/compact_index_client.rb')
-rw-r--r-- | lib/bundler/compact_index_client.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/bundler/compact_index_client.rb b/lib/bundler/compact_index_client.rb index c3a1b69c6f..3ed05ca484 100644 --- a/lib/bundler/compact_index_client.rb +++ b/lib/bundler/compact_index_client.rb @@ -29,6 +29,7 @@ module Bundler @endpoints = Set.new @info_checksums_by_name = {} @parsed_checksums = false + @mutex = Mutex.new @in_parallel = lambda do |inputs, &blk| inputs.map(&blk) end @@ -73,7 +74,7 @@ module Bundler def update(local_path, remote_path) Bundler::CompactIndexClient.debug { "update(#{local_path}, #{remote_path})" } - unless @endpoints.add?(remote_path) + unless synchronize { @endpoints.add?(remote_path) } Bundler::CompactIndexClient.debug { "already fetched #{remote_path}" } return end @@ -99,5 +100,9 @@ module Bundler def url(path) path end + + def synchronize + @mutex.synchronize { yield } + end end end |