cURL / Mailing Lists / curl-library / Single Mail

curl-library

PROPOSED CODE Re: SFTP file info and state machine

From: John Utz <john_at_utzweb.net>
Date: Thu, 3 Feb 2011 20:04:44 -0500 (EST)

----- Original Message -----
> ----- Original Message -----
> > On Mon, 31 Jan 2011, John Utz wrote:
> >
> > > i see no problem with that processing remaining where it is since
> > > it's the
> > > only state that cares about it, but that means that the 'size'
> > > variable
> > > would need to be scoped at the function level instead of the case
> > > statement
> > > level.
> > >
> > > A quick survey of the code doesnt show any conflicts with doing
> > > that.
> >
> > I didn't quite follow you (mostly due to me not spending enough time
> > to fully
> > get into the details), but can you perhaps write up a patch that
> > works
> > for you
> > and suggest here and we can discuss the details based on that?

here is what i have, absent a formal svn diff due to my employer blocking just about every port other than 80.

  case SSH_SFTP_TRANS_INIT:
      if(data->set.upload)
        state(conn, SSH_SFTP_UPLOAD_INIT);
      else {
// STUFF I ADDED BEGINS
        LIBSSH2_SFTP_ATTRIBUTES attrs;

        rc = libssh2_sftp_stat_ex(sshc->sftp_session, sftp_scp->path,
                                  (unsigned int)strlen(sftp_scp->path),
                                  LIBSSH2_SFTP_STAT, &attrs);

        if(rc == LIBSSH2_ERROR_EAGAIN) {
          break;
        }
        else if(rc != 0) {
          err = (int)(libssh2_sftp_last_error(sshc->sftp_session));
          Curl_safefree(sftp_scp->path);
          sftp_scp->path = NULL;
          state(conn, SSH_SFTP_CLOSE);
          sshc->actualcode = CURLE_QUOTE_ERROR; // not a good error for this!
          break;
        }

        data->info.filetime = attrs.mtime;
        data->req.size = attrs.filesize;
        data->req.maxdownload = attrs.filesize;
        Curl_pgrsSetDownloadSize(data, data->req.size);

// STUFF I ADDED ENDS

        if(data->set.opt_no_body)
          state(conn, SSH_STOP);
        else if(sftp_scp->path[strlen(sftp_scp->path)-1] == '/')
          state(conn, SSH_SFTP_READDIR_INIT);
        else
          state(conn, SSH_SFTP_DOWNLOAD_INIT);
      }
      break;

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-02-04