Improve sftp safe uploading and provide a safe rename workaround