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 naettGetTotalBytesRead #23

Merged
merged 18 commits into from
Jul 31, 2023
Merged

Add naettGetTotalBytesRead #23

merged 18 commits into from
Jul 31, 2023

Conversation

erkkah
Copy link
Owner

@erkkah erkkah commented Jul 31, 2023

Replaces PR #18.

This lets you implement a progress bar for downloads safely and efficiently by calling naettGetTotalBytesRead() after checking naettComplete() and finding out it's not done yet.

The first commit makes sure that res->headers only gets written to once by the various backends. This is not actually needed for the two later commits, and still doesn't technically make it safe to read headers before the full request is complete (although in practice it'll be), but it's still good practice and probably a slight performance improvement. Not implemented in linux.c though because it's less convenient to do there.

Fixes #16

@erkkah erkkah mentioned this pull request Jul 31, 2023
@erkkah
Copy link
Owner Author

erkkah commented Jul 31, 2023

@hrydgard the problem with the tests was that they were triggered on pull_request_target, which ran then in the context of the target, without the new changes.

I fixed the linux implementation, which measured the wrong byte count. On Windows, there was confusion caused by the _T macro, so I replaced that will a runtime call to winFromUTF8.

Now, it seems to work. Could you verify if it builds on MSVC?

@hrydgard
Copy link
Contributor

Builds fine. Just a single, not very unexpected warning, which we can live with I guess:

image

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.

Add getter for download progress?
2 participants