From cc852e2580575b715134cce65d6b3dc8826fe918 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 18 Feb 2010 10:47:45 -0800 Subject: Use FileUtils.mv instead of rename to copy in case of cross-device links --- activesupport/lib/active_support/core_ext/file/atomic.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/core_ext/file/atomic.rb b/activesupport/lib/active_support/core_ext/file/atomic.rb index 49d28e8a34..26b73ed442 100644 --- a/activesupport/lib/active_support/core_ext/file/atomic.rb +++ b/activesupport/lib/active_support/core_ext/file/atomic.rb @@ -14,6 +14,7 @@ class File # end def self.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 @@ -31,7 +32,7 @@ class File 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) -- cgit v1.2.3