From patchwork Fri Apr 30 10:09:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Benoit X-Patchwork-Id: 1916 Return-Path: Delivered-To: patchwork@archlinux.org Received: from mail.archlinux.org [95.216.189.61] by patchwork.archlinux.org with IMAP (fetchmail-6.4.18) for (single-drop); Fri, 30 Apr 2021 10:09:39 +0000 (UTC) Received: from mail.archlinux.org by mail.archlinux.org with LMTP id wNeuLGLXi2BRaAoAK+/4rw (envelope-from ) for ; Fri, 30 Apr 2021 10:09:38 +0000 Received: from luna.archlinux.org (luna.archlinux.org [5.9.250.164]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.archlinux.org (Postfix) with ESMTPS id 3EB7054BEF7; Fri, 30 Apr 2021 10:09:38 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id EFBF02C738; Fri, 30 Apr 2021 10:09:37 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id BF8502C734 for ; Fri, 30 Apr 2021 10:09:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.5 (2021-03-20) on luna.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001,RCVD_IN_MSPIKE_WL=0.001, T_DMARC_TESTS_FAIL=0.01 autolearn=failed autolearn_force=no version=3.4.5 X-Spam-BL-Results: [127.0.0.19] [127.0.9.2] Received: from mail.archlinux.org (mail.archlinux.org [95.216.189.61]) by luna.archlinux.org (Postfix) with ESMTPS for ; Fri, 30 Apr 2021 10:09:35 +0000 (UTC) Received: from mail.manjaro.org (mail.manjaro.org [176.9.38.148]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.archlinux.org (Postfix) with ESMTPS id C2C5A54BEF6 for ; Fri, 30 Apr 2021 10:09:34 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.manjaro.org (Postfix) with ESMTP id 585DA220B4D for ; Fri, 30 Apr 2021 12:09:34 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at manjaro.org Received: from mail.manjaro.org ([127.0.0.1]) by localhost (manjaro.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QDR4H4hgCfDN for ; Fri, 30 Apr 2021 12:09:32 +0200 (CEST) From: Guillaume Benoit To: pacman-dev@archlinux.org Message-ID: Date: Fri, 30 Apr 2021 12:09:31 +0200 MIME-Version: 1.0 Content-Language: en-US Subject: [pacman-dev] [PATCH] libalpm: fix alpm_fetch_pkgurl with a fetch callback X-BeenThere: pacman-dev@lists.archlinux.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Discussion list for pacman development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Discussion list for pacman development Errors-To: pacman-dev-bounces@lists.archlinux.org Sender: "pacman-dev" Authentication-Results: mail.archlinux.org; dkim=none; dmarc=none; spf=pass (mail.archlinux.org: domain of pacman-dev-bounces@lists.archlinux.org designates 5.9.250.164 as permitted sender) smtp.mailfrom=pacman-dev-bounces@lists.archlinux.org X-Rspamd-Queue-Id: 3EB7054BEF7 X-Spamd-Result: default: False [-0.91 / 15.00]; HAS_REPLYTO(0.00)[pacman-dev@lists.archlinux.org]; ARC_NA(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:5.9.250.164]; FORGED_SENDER_MAILLIST(0.00)[]; MIME_GOOD(-0.10)[text/plain]; REPLYTO_DOM_NEQ_FROM_DOM(0.00)[]; TO_DN_NONE(0.00)[]; HAS_LIST_UNSUB(-0.01)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_TLS_LAST(0.00)[]; RCVD_IN_DNSWL_MED(-0.40)[95.216.189.61:received,5.9.250.164:from]; DMARC_NA(0.00)[manjaro.org]; NEURAL_HAM(-0.00)[-1.000]; MAILLIST(-0.20)[mailman]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:5.9.0.0/16, country:DE]; FROM_NEQ_ENVFROM(0.00)[guillaume@manjaro.org,pacman-dev-bounces@lists.archlinux.org]; RCVD_COUNT_SEVEN(0.00)[7] X-Rspamd-Server: mail.archlinux.org After download, alpm_fetch_pkgurl uses payload->destfile_name and payload->tempfile_name in order to find the downloaded file path. Those fields are not set if a custom fetch callback is defined. Use filecache_find_url instead, like in the beginning of the function. --- lib/libalpm/dload.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index 6f33451a..d45c7707 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -1007,16 +1007,11 @@ int SYMEXPORT alpm_fetch_pkgurl(alpm_handle_t *handle, const alpm_list_t *urls, EVENT(handle, &event); } - for(i = payloads; i; i = i->next) { - struct dload_payload *payload = i->data; - char *filepath; + for(i = urls; i; i = i->next) { + char *url = i->data; - if(payload->destfile_name) { - const char *filename = mbasename(payload->destfile_name); - filepath = _alpm_filecache_find(handle, filename); - } else { - STRDUP(filepath, payload->tempfile_name, GOTO_ERR(handle, ALPM_ERR_MEMORY, err)); - } + /* attempt again to find the file in our pkgcache */ + char *filepath = filecache_find_url(handle, url); if(filepath) { alpm_list_append(fetched, filepath); } else { -- 2.31.1