From 48f729275dde424987a0c7f16963f032757e2415 Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Mon, 4 Mar 2019 23:43:31 +0000 Subject: [PATCH] fix completion calculation --- src/fetchurl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/fetchurl.c b/src/fetchurl.c index e205831..afce2cd 100644 --- a/src/fetchurl.c +++ b/src/fetchurl.c @@ -998,6 +998,7 @@ int main(int ac, char *av[]) { } do { + size_t before = io.received; if (io.response.len) { if (io.content_length && io.response.len + io.received > io.content_length) { io.response.len = io.content_length - io.received; @@ -1011,7 +1012,7 @@ int main(int ac, char *av[]) { if (progressbar) { if (io.content_length) { - pdots(50, '.', total, total+ret, + pdots(50, '.', before, io.received, io.content_length); } else { putc('\r', stderr); @@ -1051,9 +1052,9 @@ int main(int ac, char *av[]) { close(sockfd); if (progressbar && io.status_code == 200) { - if (total == io.content_length || io.content_length == 0) { + if (io.received == io.content_length || io.content_length == 0) { fprintf(stderr, " done\n"); - } else if (io.content_length != total) { + } else if (io.content_length != io.received) { fprintf(stderr, "failed (%zu bytes read)\n", total); io.status_code = 531; /* non official code */ } -- 2.40.0