Method: Bundler::Checksum::Store#replace
- Defined in:
- lib/bundler/checksum.rb
permalink #replace(spec, checksum) ⇒ Object
Replace when the new checksum is from the same source. The primary purpose is registering checksums from gems where there are duplicates of the same gem (according to full_name) in the index.
In particular, this is when 2 gems have two similar platforms, e.g. “darwin20” and “darwin-20”, both of which resolve to darwin-20. In the Index, the later gem replaces the former, so we do that here.
However, if the new checksum is from a different source, we register like normal. This ensures a mismatch error where there are multiple top level sources that contain the same gem with different checksums.
190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/bundler/checksum.rb', line 190 def replace(spec, checksum) return unless checksum lock_name = spec.name_tuple.lock_name @store_mutex.synchronize do existing = fetch_checksum(lock_name, checksum.algo) if !existing || existing.same_source?(checksum) store_checksum(lock_name, checksum) else merge_checksum(lock_name, checksum, existing) end end end |