diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2010-02-18 10:47:45 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2010-02-18 10:48:01 -0800 |
commit | cc852e2580575b715134cce65d6b3dc8826fe918 (patch) | |
tree | 4807e1948c3f18fb5d07d234fabdf54d4acdd7ed /activesupport | |
parent | a5684dfa3c16472bfa5d5d861ba78cb6dbadcb59 (diff) | |
download | rails-cc852e2580575b715134cce65d6b3dc8826fe918.tar.gz rails-cc852e2580575b715134cce65d6b3dc8826fe918.tar.bz2 rails-cc852e2580575b715134cce65d6b3dc8826fe918.zip |
Use FileUtils.mv instead of rename to copy in case of cross-device links
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/core_ext/file/atomic.rb | 3 |
1 files changed, 2 insertions, 1 deletions
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) |