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:
authorOlivier Brunel <jjk@jjacky.com>2014-01-10 16:25:17 +0100
committerAllan McRae <allan@archlinux.org>2014-03-03 11:25:54 +1000
commitbd3d1a17c2ec4297f05d092f0b93d025f811aa8a (patch)
treee141d631a1a45f08801a7c7b5f70f0db966e4078 /lib/libalpm/sync.c
parent01cc55a1f47c99d3f296e710904b5f3fc31e0b1d (diff)
Add events _PKGDOWNLOAD_{START, DONE, FAILED}
These will be emmitted when download a package file from a repository, indicating that the download starts, and whether it was successfull or not. Note that when multiple servers are available, no event is emmitted when switching to another server. (This doesn't apply to alpm_fetch_pkgurl(), but since it is called by the frontend, it shouldn't have problems knowing when the download starts and when it ends.) Signed-off-by: Olivier Brunel <jjk@jjacky.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm/sync.c')
-rw-r--r--lib/libalpm/sync.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 68c33243..96db50a3 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -897,11 +897,16 @@ static int find_dl_candidates(alpm_db_t *repo, alpm_list_t **files, alpm_list_t
static int download_single_file(alpm_handle_t *handle, struct dload_payload *payload,
const char *cachedir)
{
+ alpm_event_pkgdownload_t event = {
+ .type = ALPM_EVENT_PKGDOWNLOAD_START,
+ .file = payload->remote_name
+ };
const alpm_list_t *server;
payload->handle = handle;
payload->allow_resume = 1;
+ EVENT(handle, &event);
for(server = payload->servers; server; server = server->next) {
const char *server_url = server->data;
size_t len;
@@ -912,6 +917,8 @@ static int download_single_file(alpm_handle_t *handle, struct dload_payload *pay
snprintf(payload->fileurl, len, "%s/%s", server_url, payload->remote_name);
if(_alpm_download(payload, cachedir, NULL, NULL) != -1) {
+ event.type = ALPM_EVENT_PKGDOWNLOAD_DONE;
+ EVENT(handle, &event);
return 0;
}
@@ -919,6 +926,8 @@ static int download_single_file(alpm_handle_t *handle, struct dload_payload *pay
payload->unlink_on_fail = 0;
}
+ event.type = ALPM_EVENT_PKGDOWNLOAD_FAILED;
+ EVENT(handle, &event);
return -1;
}