lib/dload.c: Check for dlcb == NULL earlier
Our curl callback does a whole lot of work for nothing if the front end never defined a callback to receive the data we'd calculate for it. Signed-off-by: Dave Reisner <d@falconindy.com> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
47e41b2023
commit
b9263fb4e1
1 changed files with 12 additions and 10 deletions
|
@ -95,6 +95,16 @@ static int curl_progress(void *filename, double dltotal, double dlnow,
|
||||||
(void)ultotal;
|
(void)ultotal;
|
||||||
(void)ulnow;
|
(void)ulnow;
|
||||||
|
|
||||||
|
/* SIGINT sent, abort by alerting curl */
|
||||||
|
if(dload_interrupted) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* none of what follows matters if the front end has no callback */
|
||||||
|
if(handle->dlcb == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(DOUBLE_EQ(dltotal, 0) || DOUBLE_EQ(prevprogress, dltotal)) {
|
if(DOUBLE_EQ(dltotal, 0) || DOUBLE_EQ(prevprogress, dltotal)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -102,18 +112,10 @@ static int curl_progress(void *filename, double dltotal, double dlnow,
|
||||||
/* initialize the progress bar here to avoid displaying it when
|
/* initialize the progress bar here to avoid displaying it when
|
||||||
* a repo is up to date and nothing gets downloaded */
|
* a repo is up to date and nothing gets downloaded */
|
||||||
if(DOUBLE_EQ(prevprogress, 0)) {
|
if(DOUBLE_EQ(prevprogress, 0)) {
|
||||||
if(handle->dlcb) {
|
handle->dlcb((const char*)filename, 0, (long)dltotal);
|
||||||
handle->dlcb((const char*)filename, 0, (long)dltotal);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dload_interrupted) {
|
handle->dlcb((const char*)filename, (long)dlnow, (long)dltotal);
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(handle->dlcb) {
|
|
||||||
handle->dlcb((const char*)filename, (long)dlnow, (long)dltotal);
|
|
||||||
}
|
|
||||||
|
|
||||||
prevprogress = dlnow;
|
prevprogress = dlnow;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue