Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/sync.c
diff options
context:
space:
mode:
authorAnatol Pomozov <anatol.pomozov@gmail.com>2021-03-15 16:33:08 -0700
committerAllan McRae <allan@archlinux.org>2021-03-25 11:39:03 +1000
commit1e60a5f00674a9a9b0c530c741bd6701d0e1e834 (patch)
tree8539fba8183d42179f6b5504f32725bd1901de4c /lib/libalpm/sync.c
parent9bf3d6a7603bf48771a20d1f4bd789670e7446f7 (diff)
Remove "total download" callback in favor of generic event callback
Total download callback called right before packages start downloaded. But we already have an event for such event (ALPM_EVENT_PKG_RETRIEVE_START) and it is naturally to use the event to pass information about expected download size. Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm/sync.c')
-rw-r--r--lib/libalpm/sync.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index d258b8d1..7fa50a13 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -749,7 +749,7 @@ static int download_files(alpm_handle_t *handle)
const char *cachedir;
alpm_list_t *i, *files = NULL;
int ret = 0;
- alpm_event_t event;
+ alpm_event_t event = {0};
alpm_list_t *payloads = NULL;
cachedir = _alpm_filecache_setup(handle);
@@ -760,21 +760,6 @@ static int download_files(alpm_handle_t *handle)
goto finish;
}
- /* Total progress - figure out the total download size if required to
- * pass to the callback. This function is called once, and it is up to the
- * 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 = files; i; i = i->next) {
- alpm_pkg_t *spkg = i->data;
- total_size += spkg->download_size;
- howmany++;
- }
- handle->totaldlcb(howmany, total_size);
- }
-
if(files) {
/* check for necessary disk space for download */
if(handle->checkspace) {
@@ -800,6 +785,14 @@ static int download_files(alpm_handle_t *handle)
}
event.type = ALPM_EVENT_PKG_RETRIEVE_START;
+
+ /* sum up the number of packages to download and its total size */
+ for(i = files; i; i = i->next) {
+ alpm_pkg_t *spkg = i->data;
+ event.pkg_retrieve.total_size += spkg->download_size;
+ event.pkg_retrieve.num++;
+ }
+
EVENT(handle, &event);
for(i = files; i; i = i->next) {
alpm_pkg_t *pkg = i->data;