ruby-changes:63164
From: xndcn <ko1@a...>
Date: Mon, 28 Sep 2020 14:54:52 +0900 (JST)
Subject: [ruby-changes:63164] ac3f80a58e (master): [rubygems/rubygems] Add writable check for cache dir
https://git.ruby-lang.org/ruby.git/commit/?id=ac3f80a58e From ac3f80a58e1d27b92e4f6d2f5a3cff8ba530e1e3 Mon Sep 17 00:00:00 2001 From: xndcn <xndchn@g...> Date: Tue, 4 Aug 2020 13:25:59 +0800 Subject: [rubygems/rubygems] Add writable check for cache dir Sometimes "install_dir/cache" directory is not writable although "install_dir" is writable. https://github.com/rubygems/rubygems/commit/665221cb69 diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb index 20ddf47..40ac0e9 100644 --- a/lib/rubygems/remote_fetcher.rb +++ b/lib/rubygems/remote_fetcher.rb @@ -114,11 +114,12 @@ class Gem::RemoteFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/remote_fetcher.rb#L114 # always replaced. def download(spec, source_uri, install_dir = Gem.dir) + install_cache_dir = File.join install_dir, "cache" cache_dir = if Dir.pwd == install_dir # see fetch_command install_dir - elsif File.writable? install_dir - File.join install_dir, "cache" + elsif File.writable?(install_cache_dir) || (File.writable?(install_dir) && (not File.exist?(install_cache_dir))) + install_cache_dir else File.join Gem.user_dir, "cache" end diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb index 9f98f80..f6ca005 100644 --- a/test/rubygems/test_gem_remote_fetcher.rb +++ b/test/rubygems/test_gem_remote_fetcher.rb @@ -321,6 +321,8 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_remote_fetcher.rb#L321 local_path = File.join @tempdir, @a1.file_name inst = nil FileUtils.chmod 0555, @a1.cache_dir + FileUtils.mkdir_p File.join(Gem.user_dir, "cache") rescue nil + FileUtils.chmod 0555, File.join(Gem.user_dir, "cache") Dir.chdir @tempdir do inst = Gem::RemoteFetcher.fetcher @@ -329,6 +331,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_remote_fetcher.rb#L331 assert_equal(File.join(@tempdir, @a1.file_name), inst.download(@a1, local_path)) ensure + FileUtils.chmod 0755, File.join(Gem.user_dir, "cache") FileUtils.chmod 0755, @a1.cache_dir end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/