summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2021-09-27 09:13:40 +0200
committerDaniel Stenberg <daniel@haxx.se>2021-09-27 09:15:51 +0200
commit49288b224de5aef7d86ea08b00eeb92f8372b14f (patch)
treea59a195cabd9e8cc60c8be36df7165bd25649c84
parent4b997626b1182a8a7d974f2957b3ad8eaebd8817 (diff)
downloadcurl-bagder/upload-resumed-progress.tar.gz
tool_cb_prg: make resumed upload progress bar show betterbagder/upload-resumed-progress
This is a regression that was *probably* injected in the larger progress bar overhaul in 2018. Reported-by: beslick5 on github Fixes #7760
-rw-r--r--src/tool_cb_prg.c31
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;