Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormorganamilo <morganamilo@archlinux.org>2021-01-01 16:57:47 +0000
committerAllan McRae <allan@archlinux.org>2021-01-09 00:12:32 +1000
commit793e2097a6f46bbc5048c540e32a4caf92a6836a (patch)
tree7b5d063e7b7c8b9323ec58ccf074cc58cd38ddc1 /lib
parentf5b373788fce2326f98a8740fdeb9b8f7dd0a846 (diff)
libalpm: pass the number of packages being downloaded in totaldlcb
Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/alpm.h3
-rw-r--r--lib/libalpm/sync.c6
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 63d885b8..dd0036f8 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -1189,9 +1189,10 @@ typedef void (*alpm_cb_download)(const char *filename,
/** Total Download callback.
+ * @param howmany the number of packages that will be downloaded during \link alpm_trans_commit \endlink.
* @param total amount that will be downloaded during \link alpm_trans_commit \endlink.
*/
-typedef void (*alpm_cb_totaldl)(off_t total);
+typedef void (*alpm_cb_totaldl)(size_t howmany, off_t total);
/** A callback for downloading files
* @param url the URL of the file to be downloaded
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index e25e56d4..3919d266 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -760,12 +760,16 @@ static int download_files(alpm_handle_t *handle)
* frontend to compute incremental progress. */
if(handle->totaldlcb) {
off_t total_size = (off_t)0;
+ size_t howmany = 0;
/* sum up the download size for each package and store total */
for(i = handle->trans->add; i; i = i->next) {
alpm_pkg_t *spkg = i->data;
total_size += spkg->download_size;
+ if(spkg->download_size > 0) {
+ howmany++;
+ }
}
- handle->totaldlcb(total_size);
+ handle->totaldlcb(howmany, total_size);
}
ret = find_dl_candidates(handle, &files);