From 03896a9c43843208c0a5312ea879fd0971f8d1de Mon Sep 17 00:00:00 2001 From: Laurent Arnoud Date: Mon, 9 Aug 2021 10:20:26 +0000 Subject: [PATCH] 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!' ``` --- lib/discourse.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/discourse.rb b/lib/discourse.rb index c76f4c727b0..c9a7ece67a8 100644 --- a/lib/discourse.rb +++ b/lib/discourse.rb @@ -99,7 +99,7 @@ module Discourse fd.fsync() end - File.rename(temp_destination, destination) + FileUtils.mv(temp_destination, destination) nil end @@ -113,7 +113,7 @@ module Discourse FileUtils.mkdir_p(File.join(Rails.root, 'tmp')) temp_destination = File.join(Rails.root, 'tmp', SecureRandom.hex) execute_command('ln', '-s', source, temp_destination) - File.rename(temp_destination, destination) + FileUtils.mv(temp_destination, destination) nil end