X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/6226c9390d23d6868edde63b9568891cd88631cc..9f77212d7f268f8380781727b7fff520349891cd:/psftp.c diff --git a/psftp.c b/psftp.c index d07ee8b0..990bc074 100644 --- a/psftp.c +++ b/psftp.c @@ -128,8 +128,12 @@ char *canonify(char *name) assert(rreq == req); canonname = fxp_realpath_recv(pktin, rreq); - if (!canonname) - return fullname; /* even that failed; give up */ + if (!canonname) { + /* Even that failed. Restore our best guess at the + * constructed filename and give up */ + fullname[i] = '/'; /* restore slash and last component */ + return fullname; + } /* * We have a canonical name for all but the last path @@ -317,22 +321,24 @@ int sftp_get_file(char *fname, char *outfname, int recurse, int restart) * If none of them exists, of course, we start at 0. */ i = 0; - while (i < nnames) { - char *nextoutfname; - int ret; - if (outfname) - nextoutfname = dir_file_cat(outfname, - ournames[i]->filename); - else - nextoutfname = dupstr(ournames[i]->filename); - ret = (file_type(nextoutfname) == FILE_TYPE_NONEXISTENT); - sfree(nextoutfname); - if (ret) - break; - i++; - } - if (i > 0) - i--; + if (restart) { + while (i < nnames) { + char *nextoutfname; + int ret; + if (outfname) + nextoutfname = dir_file_cat(outfname, + ournames[i]->filename); + else + nextoutfname = dupstr(ournames[i]->filename); + ret = (file_type(nextoutfname) == FILE_TYPE_NONEXISTENT); + sfree(nextoutfname); + if (ret) + break; + i++; + } + if (i > 0) + i--; + } /* * Now we're ready to recurse. Starting at ournames[i] @@ -457,6 +463,7 @@ int sftp_get_file(char *fname, char *outfname, int recurse, int restart) printf("error while writing local file\n"); ret = 0; xfer_set_error(xfer); + break; } wpos += wlen; } @@ -564,23 +571,25 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart) * If none of them exists, of course, we start at 0. */ i = 0; - while (i < nnames) { - char *nextoutfname; - nextoutfname = dupcat(outfname, "/", ournames[i], NULL); - sftp_register(req = fxp_stat_send(nextoutfname)); - rreq = sftp_find_request(pktin = sftp_recv()); - assert(rreq == req); - result = fxp_stat_recv(pktin, rreq, &attrs); - sfree(nextoutfname); - if (!result) - break; - i++; - } - if (i > 0) - i--; + if (restart) { + while (i < nnames) { + char *nextoutfname; + nextoutfname = dupcat(outfname, "/", ournames[i], NULL); + sftp_register(req = fxp_stat_send(nextoutfname)); + rreq = sftp_find_request(pktin = sftp_recv()); + assert(rreq == req); + result = fxp_stat_recv(pktin, rreq, &attrs); + sfree(nextoutfname); + if (!result) + break; + i++; + } + if (i > 0) + i--; + } - /* - * Now we're ready to recurse. Starting at ournames[i] + /* + * Now we're ready to recurse. Starting at ournames[i] * and continuing on to the end of the list, we * construct a new source and target file name, and * call sftp_put_file again. @@ -2743,6 +2752,7 @@ static int psftp_connect(char *userhost, char *user, int portnumber) cfg.x11_forward = 0; cfg.agentfwd = 0; cfg.portfwd[0] = cfg.portfwd[1] = '\0'; + cfg.ssh_simple = TRUE; /* Set up subsystem name. */ strcpy(cfg.remote_cmd, "sftp");