[rubygems/rubygems] Fix gem install on NFS shares

NFS shares seem to support flock these days, but they need read-write
permissions.

https://github.com/rubygems/rubygems/commit/1c492804cd
This commit is contained in:
David Rodríguez 2024-10-09 09:13:49 +02:00 committed by git
parent 01abc2f79e
commit aad4bfd7bc
2 changed files with 4 additions and 6 deletions

View File

@ -36,15 +36,14 @@ module Gem
remove_method :open_file_with_flock if Gem.respond_to?(:open_file_with_flock)
def open_file_with_flock(path, &block)
mode = IO::RDONLY | IO::APPEND | IO::CREAT | IO::BINARY
# read-write mode is used rather than read-only in order to support NFS
mode = IO::RDWR | IO::APPEND | IO::CREAT | IO::BINARY
mode |= IO::SHARE_DELETE if IO.const_defined?(:SHARE_DELETE)
File.open(path, mode) do |io|
begin
io.flock(File::LOCK_EX)
rescue Errno::ENOSYS, Errno::ENOTSUP
rescue Errno::ENOLCK # NFS
raise unless Thread.main == Thread.current
end
yield io
end

View File

@ -808,15 +808,14 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# Open a file with given flags, and protect access with flock
def self.open_file_with_flock(path, &block)
mode = IO::RDONLY | IO::APPEND | IO::CREAT | IO::BINARY
# read-write mode is used rather than read-only in order to support NFS
mode = IO::RDWR | IO::APPEND | IO::CREAT | IO::BINARY
mode |= IO::SHARE_DELETE if IO.const_defined?(:SHARE_DELETE)
File.open(path, mode) do |io|
begin
io.flock(File::LOCK_EX)
rescue Errno::ENOSYS, Errno::ENOTSUP
rescue Errno::ENOLCK # NFS
raise unless Thread.main == Thread.current
end
yield io
end