diff options
author | Daniel Stenberg <daniel@haxx.se> | 2021-09-27 09:13:40 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2021-09-27 23:17:44 +0200 |
commit | 74e9c7790f89f20e0cfaeeea8e424414202caca5 (patch) | |
tree | af2e216e11039656420ec13bda771c7cdbe739f7 | |
parent | 15910dfd143dda791a7a3e7d515fa54c7183637a (diff) | |
download | curl-74e9c7790f89f20e0cfaeeea8e424414202caca5.tar.gz |
tool_cb_prg: make resumed upload progress bar show better
This is a regression that was *probably* injected in the larger progress
bar overhaul in 2018.
Reported-by: beslick5 on github
Fixes #7760
Closes #7777
-rw-r--r-- | src/tool_cb_prg.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/tool_cb_prg.c b/src/tool_cb_prg.c index bb93d15f8..2a23fd911 100644 --- a/src/tool_cb_prg.c +++ b/src/tool_cb_prg.c @@ -125,9 +125,6 @@ int tool_progress_cb(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) { - /* The original progress-bar source code was written for curl by Lars Aas, - and this new edition inherits some of his concepts. */ - struct timeval now = tvnow(); struct per_transfer *per = clientp; struct OperationConfig *config = per->config; @@ -135,19 +132,28 @@ int tool_progress_cb(void *clientp, curl_off_t total; curl_off_t point; - /* Calculate expected transfer size. initial_size can be less than zero - when indicating that we are expecting to get the filesize from the - remote */ - if(bar->initial_size < 0 || - ((CURL_OFF_T_MAX - bar->initial_size) < (dltotal + ultotal))) + /* Calculate expected transfer size. initial_size can be less than zero when + indicating that we are expecting to get the filesize from the remote */ + if(bar->initial_size < 0) { + if(dltotal || ultotal) + total = dltotal + ultotal; + else + total = CURL_OFF_T_MAX; + } + else if((CURL_OFF_T_MAX - bar->initial_size) < (dltotal + ultotal)) total = CURL_OFF_T_MAX; else total = dltotal + ultotal + bar->initial_size; /* Calculate the current progress. initial_size can be less than zero when indicating that we are expecting to get the filesize from the remote */ - if(bar->initial_size < 0 || - ((CURL_OFF_T_MAX - bar->initial_size) < (dlnow + ulnow))) + if(bar->initial_size < 0) { + if(dltotal || ultotal) + point = dlnow + ulnow; + else + point = CURL_OFF_T_MAX; + } + else if((CURL_OFF_T_MAX - bar->initial_size) < (dlnow + ulnow)) point = CURL_OFF_T_MAX; else point = dlnow + ulnow + bar->initial_size; @@ -215,9 +221,8 @@ void progressbarinit(struct ProgressData *bar, char *colp; memset(bar, 0, sizeof(struct ProgressData)); - /* pass this through to progress function so - * it can display progress towards total file - * not just the part that's left. (21-may-03, dbyron) */ + /* pass the resume from value through to the progress function so it can + * display progress towards total file not just the part that's left. */ if(config->use_resume) bar->initial_size = config->resume_from; |