1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-17 02:58:05 -05:00

Patch from Tim Kosse to make PSFTP remember to close files on

various error conditions.

[originally from svn r8109]
This commit is contained in:
Simon Tatham 2008-07-06 12:11:34 +00:00
parent 3c89f124db
commit 7edbe42d12

14
psftp.c
View File

@ -411,14 +411,15 @@ int sftp_get_file(char *fname, char *outfname, int recurse, int restart)
if (restart) {
char decbuf[30];
if (seek_file(file, uint64_make(0,0) , FROM_END) == -1) {
close_wfile(file);
printf("reget: cannot restart %s - file too large\n",
outfname);
sftp_register(req = fxp_close_send(fh));
rreq = sftp_find_request(pktin = sftp_recv());
assert(rreq == req);
fxp_close_recv(pktin, rreq);
sftp_register(req = fxp_close_send(fh));
rreq = sftp_find_request(pktin = sftp_recv());
assert(rreq == req);
fxp_close_recv(pktin, rreq);
return 0;
return 0;
}
offset = get_file_posn(file);
@ -643,6 +644,7 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart)
fh = fxp_open_recv(pktin, rreq);
if (!fh) {
close_rfile(file);
printf("%s: open for write: %s\n", outfname, fxp_error());
return 0;
}
@ -658,10 +660,12 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart)
ret = fxp_fstat_recv(pktin, rreq, &attrs);
if (!ret) {
close_rfile(file);
printf("read size of %s: %s\n", outfname, fxp_error());
return 0;
}
if (!(attrs.flags & SSH_FILEXFER_ATTR_SIZE)) {
close_rfile(file);
printf("read size of %s: size was not given\n", outfname);
return 0;
}