Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Gem::RemoteFetcher#atomic_copy
atomic_copy(source_path, destination_path)
lib/rubygems/remote_fetcher.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/remote_fetcher.rb, line 370
def atomic_copy(source_path, destination_path)
File.open(source_path, "rb") do |source|
# FileUtils.cp passed the source mode to File.open, so it only reached a
# file being created and the umask still applied to it. The writer
# already carries over the mode of a file it replaces.
mode = source.stat.mode & 0o777 & ~File.umask
replacing = File.exist?(destination_path)
Gem::AtomicFileWriter.open(destination_path) do |io|
IO.copy_stream(source, io)
begin
io.chmod(mode) unless replacing
rescue Errno::EPERM, Errno::EACCES
# the filesystem does not carry permissions
end
end
end
end
No documentation available