Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curl: add --remove-on-error #8503

Closed
wants to merge 1 commit into from
Closed

curl: add --remove-on-error #8503

wants to merge 1 commit into from

Conversation

bagder
Copy link
Member

@bagder bagder commented Feb 24, 2022

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

Added test 375 to verify

@bagder
Copy link
Member Author

@bagder bagder commented Feb 24, 2022

This option is actually especially useful when you download N files in parallel with -Z, as then it is much harder to script the removal of partial leftovers.

@icing
Copy link
Contributor

@icing icing commented Feb 24, 2022

Nit: curl manual already uses partial for range requests:

-r, --range
 ...
 Retrieve a byte range (i.e. a partial document) from an HTTP/1.1,

Suggestion: either change that or use a new term like incomplete?

@bagder
Copy link
Member Author

@bagder bagder commented Feb 24, 2022

Suggestion: either change that or use a new term like incomplete?

Ah yes, that's a fine observation...

@bagder
Copy link
Member Author

@bagder bagder commented Feb 24, 2022

--remove-leftover could also work

@icing
Copy link
Contributor

@icing icing commented Feb 24, 2022

Also partial content is used in the http spec for response code 206, https://datatracker.ietf.org/doc/html/rfc7233#section-4.1

But that is just one of many protocols, of course.

A download is only leftover when it is not removed, or? Seems a Schroedinger kind of problem...

@bagder
Copy link
Member Author

@bagder bagder commented Feb 24, 2022

I'll wait to see what others think about names. Alternatives to ponder:

--remove-fragment
--remove-halfway
--remove-incomplete
--remove-leftover
--remove-on-error
--remove-partial
--remove-unfinished

@Earnestly
Copy link

@Earnestly Earnestly commented Feb 24, 2022

--remove-on-error is nice and has some precdence with GNU make's .DELETE_ON_ERROR

It also encapsulates nicely the intended consequence for its purpose, which is removal upon an error.

@dfandrich
Copy link
Collaborator

@dfandrich dfandrich commented Feb 24, 2022

@BenBE
Copy link

@BenBE BenBE commented Feb 24, 2022

My favorites are --remove-on-error, --remove-incomplete, and --remove-partial. I think the --remove-on-error encapsulates its intent best. The --remove-incomplete kinda works too, but is less clear about what means "incomplete" for a download (i.e. could mean if only a part of the file was requested or sth like that). Finally with --remove-partial, while this would have been my first go-to suggestion you could cause some confusion if you perform a partial download with --range just to --remove-partial afterwards. 😉

That aside: With rsync the flag for keeping partially transferred files is --partial, thus --no-partial could be considered a viable option too. 😜

@jay
Copy link
Member

@jay jay commented Feb 24, 2022

If a transfer returns an error,

--remove-on-error

@bch
Copy link
Contributor

@bch bch commented Feb 24, 2022

@bagder bagder changed the title curl: add --remove-partial curl: add --remove-on-error Feb 24, 2022
@bagder
Copy link
Member Author

@bagder bagder commented Feb 24, 2022

--remove-on-error it is now!

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
@bagder bagder deleted the bagder/rm-partial branch Mar 10, 2022
bagder added a commit that referenced this issue Mar 10, 2022
Reported-by: Colin Leroy
Bug: #8503 (review)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants