ignore rename errors on sftp distribute
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user