diff options
author | Anatol Pomozov <anatol.pomozov@gmail.com> | 2020-05-06 04:50:51 +0200 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2020-05-09 03:58:21 +0200 |
commit | c78eb48d915dc22146073162dda08ddf73c4a508 (patch) | |
tree | 9daffa23a059dc690cb2d43a0d234f79932b0dab /lib/libalpm/alpm.h | |
parent | 64c4669f579dc5ad8d05329abffbd752ad0ed8f2 (diff) | |
download | pacman-c78eb48d915dc22146073162dda08ddf73c4a508.tar.gz pacman-c78eb48d915dc22146073162dda08ddf73c4a508.tar.xz |
Extend download callback interface with start/complete events
With the previous download interface the callback uses the first progress
event as 'download has started' signal. Unfortunately it does not work with
up-to-date files that never receive 'download progress' events.
Up-to-date database messages are currently handled in sync_syncdbs()
after the sequential download is completed and a result from ALPM is
received. But this is not going to work with multiplexed download
interface that returns the result only after all files are completed.
Another problem with 'first progress event is the beginning of the
download' is that such events time are unpredictable. Thus the UI progress
bar order might differ from what has been passed by client to
alpm_dbs_update() function. We actually want to keep the dbs progress bars
in a strict order.
To help to solve the given problems extend the download callback to
allow 2 more events - download started and completed. 'Download started'
events appear in the same order as in the list given by a client.
Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm/alpm.h')
-rw-r--r-- | lib/libalpm/alpm.h | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index a31f7a8a..534a8189 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -715,13 +715,42 @@ typedef void (*alpm_cb_progress)(alpm_progress_t, const char *, int, size_t, siz * Downloading */ +/* File download events. + * These events are reported by ALPM via download callback. + */ +typedef enum { + ALPM_DOWNLOAD_INIT, /* alpm initializes file download logic */ + ALPM_DOWNLOAD_PROGRESS, /* download progress reported */ + ALPM_DOWNLOAD_COMPLETED /* alpm is about to release data related to the file */ +} alpm_download_event_type_t; + +typedef struct { + int optional; /* whether this file is optional and thus the errors could be ignored */ +} alpm_download_event_init_t; + +typedef struct { + off_t downloaded; /* amount of data downloaded */ + off_t total; /* total amount need to be downloaded */ +} alpm_download_event_progress_t; + +typedef struct { + /* total bytes in file */ + off_t total; + /* download result code: + * 0 - download completed successfully + * 1 - the file is up-to-date + * negative - error code + */ + int result; +} alpm_download_event_completed_t; + /** Type of download progress callbacks. * @param filename the name of the file being downloaded - * @param xfered the number of transferred bytes - * @param total the total number of bytes to transfer + * @param event the event type + * @param data the event data of type alpm_download_event_*_t */ typedef void (*alpm_cb_download)(const char *filename, - off_t xfered, off_t total); + alpm_download_event_type_t event, void *data); typedef void (*alpm_cb_totaldl)(off_t total); |