curl-library
Re: POSTQUOTE rename on SFTP
Date: Sun, 30 Oct 2011 23:01:48 +0100
> On Sun, Oct 30, 2011 at 01:11:05PM +0100, Jonas Schnelli wrote:
>> I try to do a kind-of atomic upload over sftp with libcurl.
>>
>> Currently i'm sending a postquote command "rename" (after uploading a random uuid filename).
>> The rename works fine...
>> But when the destination file already exists, then the command fails with "rename command failed: Operation failed".
>>
>> Libcurl tells libssh2 LIBSSH2_SFTP_RENAME_OVERWRITE: so, the overwrite should be possible.
>
> Let me guess--the server is running Windows, right? This kind of problem has
> been reported before, and IIRC seems to have something to do with the remote
> server leaving the file open before the rename occurs. Renaming open files
> is verboten under Windows, so it errs out. Search the mailing list archives
> and you'll find some more details; I believe the conclusion was that it was
> a problem in the remote server and not libcurl, but don't quote me on that.
Hmm.. no windows.
It's a standard debian lenny (6.0) linux server.
When i do two post commands, first a rm (delete) followed by the rename, then it works perfect.
But it's a bit weak to delete the "active" file when i'm not 100% sure that the rename will work.
As soon as i have time i do some debugging in libssh2.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-10-30