curl: add --remove-on-error

If a transfer returns an error, using this option makes curl remove the
leftover downloded (partial) local file before exiting.

Added test 376 to verify

Closes #8503
This commit is contained in:
Daniel Stenberg 2022-02-24 10:30:10 +01:00
parent 7b0fd39db2
commit 08a96c6e4e
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
9 changed files with 93 additions and 2 deletions

View file

@ -595,6 +595,10 @@ static CURLcode post_per_transfer(struct GlobalConfig *global,
if(global->showerror)
fprintf(global->errors, "curl: (%d) Failed writing body\n", result);
}
if(result && config->rm_partial) {
notef(global, "Removing output file: %s", per->outfile);
unlink(per->outfile);
}
}
/* File time can only be set _after_ the file has been closed */