[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:
parent
01abc2f79e
commit
aad4bfd7bc
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user