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

fix writeto progress_func: the last chunk #375

Merged
merged 1 commit into from
Sep 9, 2022
Merged

fix writeto progress_func: the last chunk #375

merged 1 commit into from
Sep 9, 2022

Conversation

gaal-dev
Copy link

@gaal-dev gaal-dev commented Sep 9, 2022

Hello. My progree bar often stops at 99.7% or 99.8% because the last chunk can be smaller than chunk_size

        bytes_read = 0
        real_chunk = 0
        for chunk in response.iter_content(chunk_size=chunk_size):
            real_chunk += len(chunk)
            if callable(progress_func) and real_chunk - chunk_size >= 0:
                # Artifactory archives folders on fly and can reduce requested chunk size to 8kB, thus report
                # only when real chunk size met
                bytes_read += real_chunk
                real_chunk = 0
                progress_func(bytes_read, file_size)

            file.write(chunk)

        if real_chunk > 0:
            progress_func(bytes_read + real_chunk, file_size)

Copy link
Member

@beliaev-maksim beliaev-maksim left a comment

Choose a reason for hiding this comment

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

I already approved similar request that author closed for some reason

@allburov allburov merged commit 857f405 into devopshq:master Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants