]> pd.if.org Git - zpackage/commitdiff
fix completion calculation
authorNathan Wagner <nw@hydaspes.if.org>
Mon, 4 Mar 2019 23:43:31 +0000 (23:43 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Mon, 4 Mar 2019 23:43:31 +0000 (23:43 +0000)
src/fetchurl.c

index e20583119fe29de5fe969c9e9d41a0a100d21833..afce2cdf132b68594622588b23f83bafdaf0248f 100644 (file)
@@ -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 */
                }