Subject: Possible libssh2_sftp_rename_ex bug?

Possible libssh2_sftp_rename_ex bug?

From: Jonas Schnelli <>
Date: Wed, 9 Nov 2011 22:17:32 +0100


I'm using libssh2 via libcurl.
I upload some files to a sftp filespace.
I'd like to make a kind of atomically upload:

1. upload the file with a temp-filename
2. rename the file after the upload is finished

When the file (rename destination) exists, i'll always get a "Operation Failed" from sftp_libssh2_strerror.
I'm (curl's) using the LIBSSH2_SFTP_RENAME_OVERWRITE flag.

code-snippet from curl:
rc = libssh2_sftp_rename_ex(sshc->sftp_session, sshc->quote_path1,
                                  (unsigned int)strlen(sshc->quote_path1),
                                  (unsigned int)strlen(sshc->quote_path2),
                                  LIBSSH2_SFTP_RENAME_OVERWRITE |
                                  LIBSSH2_SFTP_RENAME_ATOMIC |

When the file not exists: all fine.

I'm running against linux debian lenny update version.

I tried libssh 1.3.0 (sorry, i did not test the git version because i could not find any commit which aimed on my issue).

Anyone has a idea how we can fix this?


Received on 2011-11-09