change remote file manager's upload to use a temp path + rename #2569

This commit is contained in:
r888888888
2016-01-18 18:14:04 -08:00
parent 46b32448e8
commit 42afe48d94

View File

@@ -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