mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Add writable check for cache dir
Sometimes "install_dir/cache" directory is not writable although "install_dir" is writable.
665221cb69
This commit is contained in:
parent
c55b5f1062
commit
ac3f80a58e
Notes:
git
2020-09-28 14:54:53 +09:00
2 changed files with 6 additions and 2 deletions
|
@ -114,11 +114,12 @@ class Gem::RemoteFetcher
|
|||
# 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
|
||||
|
|
|
@ -321,6 +321,8 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
|
|||
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==
|
|||
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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue