Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use FileUtils.mv instead of rename to copy in case of cross-device links

  • Loading branch information...
commit 3926107affa4307bb0df7c631deff373242cc571 1 parent 6227ec1
@jeremy jeremy authored
Showing with 2 additions and 1 deletion.
  1. +2 −1  activesupport/lib/active_support/core_ext/file/atomic.rb
View
3  activesupport/lib/active_support/core_ext/file/atomic.rb
@@ -17,6 +17,7 @@ module Atomic
# end
def atomic_write(file_name, temp_dir = Dir.tmpdir)
require 'tempfile' unless defined?(Tempfile)
+ require 'fileutils' unless defined?(FileUtils)
temp_file = Tempfile.new(basename(file_name), temp_dir)
yield temp_file
@@ -34,7 +35,7 @@ def atomic_write(file_name, temp_dir = Dir.tmpdir)
end
# Overwrite original file with temp file
- rename(temp_file.path, file_name)
+ FileUtils.mv(temp_file.path, file_name)
# Set correct permissions on new file
chown(old_stat.uid, old_stat.gid, file_name)
Please sign in to comment.
Something went wrong with that request. Please try again.