X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Fftp.c;h=cba545002d9039a936bfd18da3dcb0852387374d;hp=d3f6b18ba36eacd62e6c5fec908a74902f7da524;hb=b5c9573ad6396acf3e4e33d0ae0db65b413b0d66;hpb=6230b73df0c2a47a175f25e34ef7bfe009ddf1f9 diff --git a/src/ftp.c b/src/ftp.c index d3f6b18b..cba54500 100644 --- a/src/ftp.c +++ b/src/ftp.c @@ -1173,7 +1173,22 @@ Error in server response, closing control connection.\n")); } else if (opt.noclobber || opt.always_rest || opt.timestamping || opt.dirstruct || opt.output_document) - { + { + if (opt.unlink && file_exists_p (con->target)) + { + int res = unlink (con->target); + if (res < 0) + { + logprintf (LOG_NOTQUIET, "%s: %s\n", con->target, + strerror (errno)); + fd_close (csock); + con->csock = -1; + fd_close (dtsock); + fd_close (local_sock); + return UNLINKERR; + } + } + #ifdef __VMS int open_id; @@ -1484,6 +1499,7 @@ ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con, char **local_fi { case HOSTERR: case CONIMPOSSIBLE: case FWRITEERR: case FOPENERR: case FTPNSFOD: case FTPLOGINC: case FTPNOPASV: case CONTNOTSUPPORTED: + case UNLINKERR: /* Fatal errors, give up. */ return err; case CONSOCKERR: case CONERROR: case FTPSRVERR: case FTPRERR: