WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

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

@BSchilperoort

Description

@BSchilperoort

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions