diff options
author | Homu <homu@barosl.com> | 2016-08-11 23:47:45 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-08-11 23:47:45 +0900 |
commit | 4a4b837a2a37d0ac5dd04bb61a2fee19424a03ac (patch) | |
tree | 52e108ebfed32bc48f7cd7f97639b08a668b33cc | |
parent | c0e10ebf782b902ed1870f387c5e0268fb398a98 (diff) | |
parent | b0119a002fd58fd3d5a7cab53b90d2753f10cc78 (diff) | |
download | bundler-4a4b837a2a37d0ac5dd04bb61a2fee19424a03ac.tar.gz |
Auto merge of #4867 - bundler:seg-info-case, r=indirect
Add resiliency against case conflicts on a case-insensitive FS
Closes #4864
3 files changed, 37 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 1679c17c8a..9ab2722f18 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 @@ -60,9 +60,8 @@ class Bundler::CompactIndexClient private def update(local_path, remote_path) - return if @endpoints.include?(remote_path) + return unless @endpoints.add?(remote_path) @updater.update(local_path, url(remote_path)) - @endpoints << remote_path end def update_info(name) diff --git a/lib/bundler/vendor/compact_index_client/lib/compact_index_client/cache.rb b/lib/bundler/vendor/compact_index_client/lib/compact_index_client/cache.rb index a370fa402d..d2639ee717 100644 --- a/lib/bundler/vendor/compact_index_client/lib/compact_index_client/cache.rb +++ b/lib/bundler/vendor/compact_index_client/lib/compact_index_client/cache.rb @@ -1,11 +1,12 @@ # frozen_string_literal: true +require "digest/md5" class Bundler::CompactIndexClient class Cache attr_reader :directory def initialize(directory) @directory = Pathname.new(directory).expand_path - FileUtils.mkdir_p info_path(nil) + info_roots.each {|dir| FileUtils.mkdir_p(dir) } end def names @@ -59,7 +60,13 @@ class Bundler::CompactIndexClient end def info_path(name) - directory.join("info", name.to_s) + name = name.to_s + if name =~ /[^a-z0-9_-]/ + name += "-#{Digest::MD5.hexdigest(name).downcase}" + info_roots.last.join(name) + else + info_roots.first.join(name) + end end def specific_dependency(name, version, platform) @@ -94,5 +101,12 @@ class Bundler::CompactIndexClient dependency[-1] = dependency[-1].split("&") if dependency.size > 1 dependency end + + def info_roots + [ + directory.join("info"), + directory.join("info-special-characters"), + ] + end end end diff --git a/spec/install/gems/compact_index_spec.rb b/spec/install/gems/compact_index_spec.rb index 05137c9ffe..0edd1d20e7 100644 --- a/spec/install/gems/compact_index_spec.rb +++ b/spec/install/gems/compact_index_spec.rb @@ -44,6 +44,26 @@ describe "compact index api" do ) end + it "should handle case sensitivity conflicts" do + build_repo4 do + build_gem "rack", "1.0" do |s| + s.add_runtime_dependency("Rack", "0.1") + end + build_gem "Rack", "0.1" + end + + install_gemfile! <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4 } + source "#{source_uri}" + gem "rack", "1.0" + gem "Rack", "0.1" + G + + # can't use `include_gems` here since the `require` will conflict on a + # case-insensitive FS + run! "Bundler.require; puts Gem.loaded_specs.values_at('rack', 'Rack').map(&:full_name)" + expect(out).to eq("rack-1.0\nRack-0.1") + end + it "should handle multiple gem dependencies on the same gem" do gemfile <<-G source "#{source_uri}" |