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>
This commit is contained in:
parent
eb1a63a516
commit
72238aa046
2 changed files with 19 additions and 11 deletions
|
@ -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.
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue