change remote file manager's upload to use a temp path + rename #2569
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
require 'securerandom'
|
||||||
|
|
||||||
class RemoteFileManager
|
class RemoteFileManager
|
||||||
attr_reader :path
|
attr_reader :path
|
||||||
|
|
||||||
@@ -6,9 +8,13 @@ class RemoteFileManager
|
|||||||
end
|
end
|
||||||
|
|
||||||
def distribute
|
def distribute
|
||||||
|
uuid = SecureRandom.uuid
|
||||||
|
temp_path = "/tmp/rfm-#{Danbooru.config.hostname}-#{uuid}"
|
||||||
|
|
||||||
Danbooru.config.other_server_hosts.each do |hostname|
|
Danbooru.config.other_server_hosts.each do |hostname|
|
||||||
Net::SFTP.start(hostname, Danbooru.config.remote_server_login) do |ftp|
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user