diff --git a/app/logical/remote_file_manager.rb b/app/logical/remote_file_manager.rb index e80e0ce68..05480f582 100644 --- a/app/logical/remote_file_manager.rb +++ b/app/logical/remote_file_manager.rb @@ -1,3 +1,5 @@ +require 'securerandom' + class RemoteFileManager attr_reader :path @@ -6,9 +8,13 @@ class RemoteFileManager end def distribute + uuid = SecureRandom.uuid + temp_path = "/tmp/rfm-#{Danbooru.config.hostname}-#{uuid}" + Danbooru.config.other_server_hosts.each do |hostname| Net::SFTP.start(hostname, Danbooru.config.remote_server_login) do |ftp| - ftp.upload!(path, path) + ftp.upload!(path, temp_path) + ftp.rename!(temp_path, path) end end end