cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: sftp postquote command rename fix/diff question

From: Kristian Gunstone <kristian.gunstone_at_pean.org>
Date: Thu, 10 May 2007 00:24:22 +0200

* Dan Fandrich <dan_at_coneharvesters.com> [2007-05-09 22:46:32]:
> On Wed, May 09, 2007 at 10:20:04PM +0200, Kristian Gunstone wrote:
> > Yes, I suppose you're right. However, the error returned is
> > LIBSSH2_FX_FAILURE, or "Operation failed".
>
> Yes, this is a known problem with curl's SSH support. Patches would
> be welcome!
>
> > This could pretty much be anything unless you actually
> > called libssh2_sftp_stat from outside libcurl, which would seem to
> > make libcurl almost redundant for this use.
> >
> > Do you have a suggestion how I could solve this dilemman or come with a
> > better general solution?
>
> The curl functions sftp_libssh2_error_to_CURLE and
> libssh2_session_error_to_CURLE are the obvious places to add more
> verbose error reporting. Existing curl error codes for similar errors
> can be reused.
>
> >>> Dan
> --
> http://www.MoveAnnouncer.com The web change of address service
> Let webmasters know that your web site has moved
>

Ok, here we go:

http://www.pulia.nu/code/junk/curl-lib_ssh_c-sftp_rename-rm_fix.diff

This patch has modifications to the rename and rm handlers in lib/ssh.c.
As tipped, I'm now just returning an error if rename fails due to
destination already existing.

In order to test this, I also had to make modifications to the file
delete handler at the same time, since it also returns an unknown error
to the user application if the file does _not_ exist, and thus I added
support for this return code at the same time.

Seems to work properly now, but it sure makes renaming slow for user
applications since the entire connection has to be reestablished between
rename, delete, and reattempt to rename (that's how it is right now for
                                         sftp it seems)

Well, hope you prefer this method.

Time for bed!

-- 
Kristian Gunstone
http://www.pulia.nu
Received on 2007-05-10