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

Add file (size) validation when files already exist #161

Open
BSchilperoort opened this issue Dec 12, 2023 · 0 comments
Open

Add file (size) validation when files already exist #161

BSchilperoort opened this issue Dec 12, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@BSchilperoort
Copy link
Member

We could try to enhance the check for file existance by validating the file size. This way we can differentiate fully downloaded files from files where the download was interrupted.

import cdsapi
c = cdsapi.Client()
r = c.retrieve(...) # make a request and start the downloading process
r.content_length # bytes
>>> 65337064

r.content_length will return the size of the file in bytes. This can be compared to Path(...).stat().st_size.

This way we can skip existing files if they match the right content_length, and otherwise overwrite them.

Originally posted by @BSchilperoort in #155 (comment)

@BSchilperoort BSchilperoort added the enhancement New feature or request label Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant