X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Fhttp.c;h=6d9b1e9b70c88c65973153d93e07f2d401962abf;hp=0b1d644bb6e3803ef70086bbd77780855a53a715;hb=b5c9573ad6396acf3e4e33d0ae0db65b413b0d66;hpb=6230b73df0c2a47a175f25e34ef7bfe009ddf1f9 diff --git a/src/http.c b/src/http.c index 0b1d644b..6d9b1e9b 100644 --- a/src/http.c +++ b/src/http.c @@ -2486,6 +2486,19 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file)); } else if (ALLOW_CLOBBER) { + if (opt.unlink && file_exists_p (hs->local_file)) + { + int res = unlink (hs->local_file); + if (res < 0) + { + logprintf (LOG_NOTQUIET, "%s: %s\n", hs->local_file, + strerror (errno)); + CLOSE_INVALIDATE (sock); + xfree (head); + return UNLINKERR; + } + } + #ifdef __VMS int open_id; @@ -2782,6 +2795,13 @@ Spider mode enabled. Check if remote file exists.\n")); logprintf (LOG_NOTQUIET, _("Unable to establish SSL connection.\n")); ret = err; goto exit; + case UNLINKERR: + /* Another fatal error. */ + logputs (LOG_VERBOSE, "\n"); + logprintf (LOG_NOTQUIET, _("Cannot unlink %s (%s).\n"), + quote (hstat.local_file), strerror (errno)); + ret = err; + goto exit; case NEWLOCATION: /* Return the new location to the caller. */ if (!*newloc)