Re: SFTP create missing directories
Date: Tue, 12 Jun 2007 17:21:27 +0200
On Tuesday, 12. June 2007, James Housley wrote:
> On Jun 12, 2007, at 10:17 AM, Daniel Stenberg wrote:
> > On Tue, 12 Jun 2007, James Housley wrote:
> >> So following that precedent, I would like to do a
> >> libssh2_sftp_opendir() to see if the directory exists. I believe
> >> that should give a definitive answer about the existence of the
> >> destination directory. If it doesn't exist, the call the
> >> sftp_create_dirs() routine. Then try the libssh2_sftp_open() to
> >> start the upload.
> >> How does that sound?
> > It does provide the most proper solution that will make libcurl not
> > attempt to create a dir just because it failed for other reasons,
> > but on the other hand it'll use quite a lot of more time and
> > roundtrips if there's a really deep dir hiearchy to traverse...
> My other question is what will creating an existing directory do on
> the remote end? Could it change the owner? Could it change the
> permissions? Not creating is very safe.
Thats a question I still ponder too, as I tried to convey via the small
comment before the libssh2_sftp_mkdir() call.
> > I'm not sure the benefits outweights the downside of the slower
> > operation. But I don't feel strongly for either way so if your
> > poking on this I'm fine to let you pick the way you like.
> I think I will use opendir because I feel the results will be better
> defined. But I have testing to do, one question is if we want to
> upload to a directory "something", but there already is a file called
In the application I develop, this must fail - and I think it should fail in
I append a third patch in which I tried to follow your suggestions as I
understood them - I might be completly off the mark though - the new version
tries to open the target directory and if that failes calls the
sftp_create_dirs function as before.
In either place I would like to react more specific on the cause of failure
(in case of failure) - to get to a point where I try to continue only if its
sane behaviour - but all I get as return codes from libssh2 are
LIBSSH2_FX_FAILURE, so at the moment my code continues in that case too, as
> > > On a side note, the patch uses index() but isn't strchr() more widely
> > > supported?
> > Exactly, we should use strchr().
This is done also (a look at the manpages "conformant to" sections was
-- Tom Regner -- Jabber: tomte_at_tomsdiner.org http://www.tomsdiner.org
- text/x-diff attachment: sftp_cmds_3.patch
- application/pgp-signature attachment: This is a digitally signed message part.