ignore rename errors on sftp distribute

This commit is contained in:
r888888888
2016-01-19 10:34:02 -08:00
parent 42afe48d94
commit 802b31a34e

View File

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