eWaterCycle / eWaterCycle/era5cli

Add file (size) validation when files already exist

Open
#161 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
59
Forks
8
PR merge metrics
No merged PRs in 30d

Description

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.

```py
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 https://github.com/eWaterCycle/era5cli/issues/155#issuecomment-1638227753_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.