axel-download-accelerator / axel

Lightweight CLI download accelerator
GNU General Public License v2.0
2.85k stars 258 forks source link

Progress indicator is messed up in axel 2.17.4 #228

Closed foutrelis closed 4 years ago

foutrelis commented 4 years ago

The alternate progress indicator seems to work fine, but the default one is all over the place. Attaching screenshots below but could also try a git bisect if it's not reproducible on your end.

2.17.3 vs 2.17.4:

Screenshot_2019-07-20_13-00-47

Screenshot_2019-07-20_13-01-23

ismaell commented 4 years ago

Weird. I didn't see that happening. Please do a bisect.

foutrelis commented 4 years ago

Bisect points to ef6ccfc4a38fc78c0c9fa18a4731dbac1f10ea49. The issue is always reproducible with axel http://speed.hetzner.de/1GB.bin. Weirdly enough, downloading the same file over HTTPS shows properly aligned progress output.

Reverting part of the above commit seems to fix this strange issue:

diff --git a/src/text.c b/src/text.c
index 5bd36aa..861aab5 100644
--- a/src/text.c
+++ b/src/text.c
@@ -403,7 +403,7 @@ main(int argc, char *argv[])
                                print_alternate_output(axel);
                } else {
                        /* The infamous wget-like 'interface'.. ;) */
-                       size_t done = (axel->bytes_done - prev) / 1024;
+                       size_t done = (axel->bytes_done / 1024) - (prev / 1024);
                        if (done && conf->verbose > -1) {
                                for (size_t i = 0; i < done; i++) {
                                        i += (prev / 1024);
ismaell commented 4 years ago

Excellent. I see what happened now. Do you mind to do a PR?

ismaell commented 4 years ago

Remeber to add a reference to this issue's URL and the commit that introduced the bug.

ismaell commented 4 years ago

Thanks.

ismaell commented 4 years ago

You may want to check the changes I just made. I double checked this time.

ismaell commented 4 years ago

This probably should be further simplified.

foutrelis commented 4 years ago

It still looks good here and the code seems much cleaner. :+1:

(The current code isn't too complicated in my opinion.)