From df6f33d182a0453ae096995cbd941ba9690fd78f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Thu, 29 Jun 2000 08:39:29 +0000 Subject: [PATCH] Don't forget to delete the output file if the request fails. Don't delete the output file if -r was specified. --- usr.bin/fetch/fetch.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr.bin/fetch/fetch.c b/usr.bin/fetch/fetch.c index d063100d126..48d3da17530 100644 --- a/usr.bin/fetch/fetch.c +++ b/usr.bin/fetch/fetch.c @@ -293,6 +293,8 @@ fetch(char *URL, char *path) /* start the transfer */ if ((f = fetchGet(url, flags)) == NULL) { warnx("%s", fetchLastErrString); + if (!R_flag && !r_flag && !o_stdout) + unlink(path); goto failure; } @@ -358,7 +360,7 @@ fetch(char *URL, char *path) if (ferror(of)) warn("%s", path); if (ferror(f) || ferror(of)) { - if (!R_flag && !o_stdout) + if (!R_flag && !r_flag && !o_stdout) unlink(path); goto failure; }