I have to regularly update a file on a server using SFTP transfer and libcurl. From many sources and personal experience I discovered that rename command using curl with SFTP fails when the destination path points to already existing file. But sftp client does not work that way - the same command overwrites the existing file. Isn't there really way to force this behaviour on libcurl. I am aware of the option of deleting the file first, but then comes the problem that it fails if the file doesn't exists and it is still a workaround rather than a solution to me.
Edit: libcurl raises the LIBSSH2_SFTP_RENAME_OVERWRITE flag of libssh2_sftp_rename_ex but it seems to not work for some versions of the protocol/server
Workaround: add commands "*rm" which points that rm can fail