diff options
author | Andrew Gregory <andrew.gregory.8@gmail.com> | 2021-04-28 04:11:27 +0200 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2021-05-01 04:08:14 +0200 |
commit | 72238aa046b8a8de1c7b9110726986c7538023b5 (patch) | |
tree | e5cb6ee1d6f489cd06fae2e87aec9cad5e9cd16a | |
parent | eb1a63a516cb3791d0084b0d05b074c963aa01e9 (diff) | |
download | pacman-72238aa046b8a8de1c7b9110726986c7538023b5.tar.gz pacman-72238aa046b8a8de1c7b9110726986c7538023b5.tar.xz |
call download progress callback for signatures
pacman may not care about them, but other front-ends do.
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
-rw-r--r-- | lib/libalpm/dload.c | 18 | ||||
-rw-r--r-- | src/pacman/callback.c | 12 |
2 files changed, 19 insertions, 11 deletions
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index 935f5418..8fa46bb2 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -166,11 +166,6 @@ static int dload_progress_cb(void *file, curl_off_t dltotal, curl_off_t dlnow, off_t current_size, total_size; alpm_download_event_progress_t cb_data = {0}; - /* do not print signature files progress bar */ - if(payload->signature) { - return 0; - } - /* avoid displaying progress bar for redirects with a body */ if(payload->respcode >= 300) { return 0; @@ -669,7 +664,7 @@ cleanup: unlink(payload->tempfile_name); } - if(handle->dlcb && !payload->signature) { + if(handle->dlcb) { alpm_download_event_completed_t cb_data = {0}; cb_data.total = bytes_dl; cb_data.result = ret; @@ -782,6 +777,12 @@ static int curl_add_payload(alpm_handle_t *handle, CURLM *curlm, curl_easy_setopt(curl, CURLOPT_WRITEDATA, payload->localf); curl_multi_add_handle(curlm, curl); + + if(handle->dlcb) { + alpm_download_event_init_t cb_data = {.optional = payload->errors_ok}; + handle->dlcb(handle->dlcb_ctx, payload->remote_name, ALPM_DOWNLOAD_INIT, &cb_data); + } + return 0; cleanup: @@ -810,11 +811,6 @@ static int curl_download_internal(alpm_handle_t *handle, struct dload_payload *payload = payloads->data; if(curl_add_payload(handle, curlm, payload, localpath) == 0) { - if(handle->dlcb && !payload->signature) { - alpm_download_event_init_t cb_data = {.optional = payload->errors_ok}; - handle->dlcb(handle->dlcb_ctx, payload->remote_name, ALPM_DOWNLOAD_INIT, &cb_data); - } - payloads = payloads->next; } else { /* The payload failed to start. Do not start any new downloads. diff --git a/src/pacman/callback.c b/src/pacman/callback.c index c3563af3..ae7e1bed 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -1070,10 +1070,22 @@ static void dload_complete_event(const char *filename, alpm_download_event_compl } } +static int strendswith(const char *haystack, const char *needle) +{ + size_t hlen = strlen(haystack), nlen = strlen(needle); + return hlen >= nlen && strcmp(haystack + hlen - nlen, needle) == 0; +} + /* Callback to handle display of download progress */ void cb_download(void *ctx, const char *filename, alpm_download_event_type_t event, void *data) { (void)ctx; + + /* do not print signature files progress bar */ + if(strendswith(filename, ".sig")) { + return; + } + if(event == ALPM_DOWNLOAD_INIT) { dload_init_event(filename, data); } else if(event == ALPM_DOWNLOAD_PROGRESS) { |