[pacman-dev] [PATCH] libalpm: download signatures with a fetch callback
Remove an unwanted break and download signatures when using a custom fetch callback. --- lib/libalpm/dload.c | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index a4c42f8d..6f33451a 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -877,9 +877,26 @@ int _alpm_download(alpm_handle_t *handle, int success = 0; if(payload->fileurl) { - if (handle->fetchcb(payload->fileurl, localpath, payload->force) != -1) { - success = 1; - break; + int ret; + + ret = handle->fetchcb(payload->fileurl, localpath, payload->force); + + if (ret != -1) { + /* Let's check if client requested downloading accompanion *.sig file */ + if(payload->download_signature) { + char *sig_fileurl; + + size_t sig_len = strlen(payload->fileurl) + 5; + MALLOC(sig_fileurl, sig_len, RET_ERR(handle, ALPM_ERR_MEMORY, -1)); + snprintf(sig_fileurl, sig_len, "%s.sig", payload->fileurl); + + ret = handle->fetchcb(sig_fileurl, localpath, payload->force); + + free(sig_fileurl); + } + if (ret != -1) { + success = 1; + } } } else { for(s = payload->servers; s; s = s->next) { @@ -892,12 +909,26 @@ int _alpm_download(alpm_handle_t *handle, snprintf(fileurl, len, "%s/%s", server, payload->filepath); ret = handle->fetchcb(fileurl, localpath, payload->force); - free(fileurl); if (ret != -1) { - success = 1; - break; + /* Let's check if client requested downloading accompanion *.sig file */ + if(payload->download_signature) { + char *sig_fileurl; + + size_t sig_len = strlen(fileurl) + 5; + MALLOC(sig_fileurl, sig_len, RET_ERR(handle, ALPM_ERR_MEMORY, -1)); + snprintf(sig_fileurl, sig_len, "%s.sig", fileurl); + + ret = handle->fetchcb(sig_fileurl, localpath, payload->force); + + free(sig_fileurl); + } + if (ret != -1) { + success = 1; + break; + } } + free(fileurl); } } if(!success && !payload->errors_ok) { -- 2.31.1
participants (1)
-
Guillaume Benoit