Vysp3r / ProtonPlus

A modern compatibility tools manager for Linux.
GNU General Public License v3.0
247 stars 12 forks source link

[FEATURE] "Bytes downloaded" progress bar #205

Closed Arcitec closed 2 months ago

Arcitec commented 2 months ago

I just noticed that there was a question in one of the PRs and I hadn't seen it before.

How would you display the progress if we used the way you mentioned?

Something like this 1.56/2.85 MB

Or maybe something else?

The problem when GitHub is creating a zip is that we don't know how large the full file will be. Even GitHub doesn't know. So it sends Content-Length: 0 and then starts creating a zip/tar which gets directly piped into the web server output.

So even a web browser that downloads those archives from GitHub just shows how much it's currently received, such as "102.1 MiB", "180.6 MiB", etc etc, with a basic spinner, without any progress bar (since it doesn't know), until it's finally done.

In that scenario, we only know one value: The current bytes downloaded.

Therefore the only thing we can do for the user is to have two types of progress displays:

This would indeed be a robust improvement which is unrelated to the STL implementation, so I created this ticket to track that.

The main thing to be able to implement this is to change the Download handler's progress_callback to take 2 parameters (int64 progress and bool is_percentage). And yeah I think we should fetch the downloaded bytes (and calculated progress) as a 64-bit integer just to be safe, since 32-bit ints can only fit file sizes up to \~4 GiB. (Which is precisely why the human-readable size converter is already defined as covert_bytes_to_string (int64 size). :))

Then, the progress_callback is responsible for rendering as a % if it received a percentage value, otherwise convert it to bytes and display as human-readable file size (rendered in the same text-label as the percentage would use).


Edit: I haven't done a full review of src/utils/web.vala, but a quick glance seems like it's almost 64-bit aware.

Arcitec commented 2 months ago

I've implemented this and forgot to close this ticket. Here we go. 😅

Edit: It was implemented in this PR: https://github.com/Vysp3r/ProtonPlus/pull/208/commits