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

Skip download if there is an existing file of the right length. #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

davidbau
Copy link

@davidbau davidbau commented Aug 1, 2021

To facilitate resumption of downloads: when there is an existing downloaded file of precisely the right length, do not bother re-downloading that file.

Addresses #15

Copy link
Owner

@dimazest dimazest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, just a minor comment.

Thank you for the contribution.

server_length = int(request.raw.headers['Content-Length'])
local_length = os.stat(output.join(fname)).st_size
if server_length == local_length:
print('Skipping', fname, ': already have', local_length, 'bytes')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print('Skipping', fname, ': already have', local_length, 'bytes')
print(f'Skipping {fname}: already has{local_length} bytes.', file=sys.stderr)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants