libalpm: pass the number of packages being downloaded in totaldlcb

Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
morganamilo 2021-01-01 16:57:47 +00:00 committed by Allan McRae
parent f5b373788f
commit 793e2097a6
4 changed files with 10 additions and 4 deletions

View file

@ -1189,9 +1189,10 @@ typedef void (*alpm_cb_download)(const char *filename,
/** Total Download callback. /** 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. * @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 /** A callback for downloading files
* @param url the URL of the file to be downloaded * @param url the URL of the file to be downloaded

View file

@ -760,12 +760,16 @@ static int download_files(alpm_handle_t *handle)
* frontend to compute incremental progress. */ * frontend to compute incremental progress. */
if(handle->totaldlcb) { if(handle->totaldlcb) {
off_t total_size = (off_t)0; off_t total_size = (off_t)0;
size_t howmany = 0;
/* sum up the download size for each package and store total */ /* sum up the download size for each package and store total */
for(i = handle->trans->add; i; i = i->next) { for(i = handle->trans->add; i; i = i->next) {
alpm_pkg_t *spkg = i->data; alpm_pkg_t *spkg = i->data;
total_size += spkg->download_size; 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); ret = find_dl_candidates(handle, &files);

View file

@ -694,8 +694,9 @@ void cb_progress(alpm_progress_t event, const char *pkgname, int percent,
} }
/* callback to handle receipt of total download value */ /* callback to handle receipt of total download value */
void cb_dl_total(off_t total) void cb_dl_total(size_t howmany, off_t total)
{ {
(void)howmany;
list_total = total; list_total = total;
} }

View file

@ -36,7 +36,7 @@ void cb_progress(alpm_progress_t event, const char *pkgname, int percent,
size_t howmany, size_t remain); size_t howmany, size_t remain);
/* callback to handle receipt of total download value */ /* callback to handle receipt of total download value */
void cb_dl_total(off_t total); void cb_dl_total(size_t howmany, off_t total);
/* callback to handle display of download progress */ /* callback to handle display of download progress */
void cb_download(const char *filename, alpm_download_event_type_t event, void cb_download(const char *filename, alpm_download_event_type_t event,
void *data); void *data);