diff --git a/app/logical/remote_file_manager.rb b/app/logical/remote_file_manager.rb index 05480f582..c67266fbe 100644 --- a/app/logical/remote_file_manager.rb +++ b/app/logical/remote_file_manager.rb @@ -9,12 +9,18 @@ class RemoteFileManager def distribute uuid = SecureRandom.uuid - temp_path = "/tmp/rfm-#{Danbooru.config.hostname}-#{uuid}" + temp_path = "/tmp/rfm-#{Danbooru.config.server_host}-#{uuid}" Danbooru.config.other_server_hosts.each do |hostname| Net::SFTP.start(hostname, Danbooru.config.remote_server_login) do |ftp| ftp.upload!(path, temp_path) - ftp.rename!(temp_path, path) + begin + ftp.rename!(temp_path, path) + rescue Net::SFTP::StatusException + # this typically means the file already exists + # so just clean up + ftp.remove(temp_path) + end end end end