SFTP MoveToFile fails if destination file already exists
dhondgepooja opened this issue · comments
If SFTP MoveToFile is attempting to move file from sftp location to another sftp location that already has the file with same name, it fails with debug1: read eof
and returns sftp: "Failure" (SSH_FX_FAILURE)
. SFTP renaming doesn't support renaming as per following details. Hence we should remove the file before rename if it already exists.
Files (and directories) can be renamed using the SSH_FXP_RENAME
message. Its data is as follows:
uint32 id
string oldpath
string newpath
where `id' is the request identifier, `oldpath' is the name of an
existing file or directory, and `newpath' is the new name for the
file or directory. It is an error if there already exists a file
with the name specified by newpath. The server may also fail rename
requests in other situations, for example if `oldpath' and `newpath'
point to different file systems on the server.