FIX: Errno::EXDEV when across filesystem boundaries (#13976)

ref https://bugs.ruby-lang.org/issues/12615

```
        W: rake aborted!
        W: Errno::EXDEV: Invalid cross-device link @ rb_file_s_rename - (/app/tmp/adeeee62504de67238341871bda1aaf0, /app/app/assets/javascripts/plugins/discourse-cakeday.js.e
rb)
        W: lib/discourse.rb:65:in `rename'
        W: lib/discourse.rb:65:in `atomic_write_file'
        W: /app/lib/plugin/instance.rb:683:in `activate!'
        W: lib/discourse.rb:246:in `block in activate_plugins!'
        W: lib/discourse.rb:243:in `each'
        W: lib/discourse.rb:243:in `activate_plugins!'
```
This commit is contained in:
Laurent Arnoud 2021-08-09 10:20:26 +00:00 committed by GitHub
parent e68c1d5ba5
commit 03896a9c43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -99,7 +99,7 @@ module Discourse
fd.fsync() fd.fsync()
end end
File.rename(temp_destination, destination) FileUtils.mv(temp_destination, destination)
nil nil
end end
@ -113,7 +113,7 @@ module Discourse
FileUtils.mkdir_p(File.join(Rails.root, 'tmp')) FileUtils.mkdir_p(File.join(Rails.root, 'tmp'))
temp_destination = File.join(Rails.root, 'tmp', SecureRandom.hex) temp_destination = File.join(Rails.root, 'tmp', SecureRandom.hex)
execute_command('ln', '-s', source, temp_destination) execute_command('ln', '-s', source, temp_destination)
File.rename(temp_destination, destination) FileUtils.mv(temp_destination, destination)
nil nil
end end