mirror of
https://github.com/curl/curl.git
synced 2026-07-23 20:17:15 +03:00
tool_operate: make --remove-on-error only remove "real" files
Reported-by: Harry Sintonen Assisted-by: Dan Fandrich Closes #12710
This commit is contained in:
parent
c5801a28c5
commit
ae9f01f336
2 changed files with 12 additions and 3 deletions
|
|
@ -12,4 +12,4 @@ When curl returns an error when told to save output in a local file, this
|
|||
option removes that saved file before exiting. This prevents curl from
|
||||
leaving a partial file in the case of an error during transfer.
|
||||
|
||||
If the output is not a file, this option has no effect.
|
||||
If the output is not a regular file, this option has no effect.
|
||||
|
|
|
|||
|
|
@ -637,8 +637,17 @@ noretry:
|
|||
errorf(config->global, "curl: (%d) Failed writing body", result);
|
||||
}
|
||||
if(result && config->rm_partial) {
|
||||
notef(global, "Removing output file: %s", outs->filename);
|
||||
unlink(outs->filename);
|
||||
struct_stat st;
|
||||
if(!stat(outs->filename, &st) &&
|
||||
S_ISREG(st.st_mode)) {
|
||||
if(!unlink(outs->filename))
|
||||
notef(global, "Removed output file: %s", outs->filename);
|
||||
else
|
||||
warnf(global, "Failed removing: %s", outs->filename);
|
||||
}
|
||||
else
|
||||
warnf(global, "Skipping removal; not a regular file: %s",
|
||||
outs->filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue