From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id iIloHOjfJGZOZwEAqHPOHw:P1 (envelope-from ) for ; Sun, 21 Apr 2024 11:44:08 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id iIloHOjfJGZOZwEAqHPOHw (envelope-from ) for ; Sun, 21 Apr 2024 11:44:08 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1713692648; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=IQruu4tT6+Uqv3JCPa0gIz1l9ClaLbVxGn0j8nQrb8U=; b=Shf32cY3wj3smy5fnpGMgwk+YGegRu1UBwE4RShpQelaoUzW73LQ3h22eLtNYrY1ljbGzT MjEDVH2BZgAwTamMidNHqcf1WKuXRSH7m3lbkMhGo4kzyW96dDWbeZjzOlY0DHE2JLO74f g5D4zsb5rVE85j2aad7S7EiSb6BlciDNpngo6xjQsoJQeusfmILcTMxMD2/ksuRZZk9UIR ytDWZhfPppATmtJQhyaox9spozl6fYaqfNyo+QtVovbp0Kxzx1M3xMDvrkW24n8vn4FYlG 70v12N2JWeSoG/pxNEGkI1ihaXD5I/68vhmT9ggwYnu1vzCAsbnzczvp3evctg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1713692648; a=rsa-sha256; cv=none; b=qFp9fcVxBiH6LZ+qiItV42kDINBNJ7MWmqhjNrM+o7AJ05WbBAjhj47E8WD3t3ZeyvJgQV ddoJik57v4xl090O01cbUzYmwDq0APTxhkUlaDXOSUGKSt+uzl9j8+kECsQte5lEBkC/a7 xlScXjehMIlxrEVmAI5u+q/3Cm8ZkpUktzpX/HXedGkxrsCiykc6lCxAnPzJnTBLPBum8G EN+3uShG3tJqYyH0i+43Xan8y5M4u1IBPM6gr1VfmHpIA5DP3ydD/zFyiUSiXGyEfyIn8h +z0DJvhomD8/U16B5iKb44RuvJC0nfRHtMijLi8HYNheuFXrIE+7/+gGq3So2g== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 307BA3AFE4 for ; Sun, 21 Apr 2024 11:44:07 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ryTjy-0005WN-ON; Sun, 21 Apr 2024 05:44:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ryTjo-0005Sl-8e for guix-patches@gnu.org; Sun, 21 Apr 2024 05:43:56 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ryTjn-0002pv-Vz; Sun, 21 Apr 2024 05:43:56 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ryTk2-0006WM-JJ; Sun, 21 Apr 2024 05:44:10 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70494] [PATCH 18/23] guix: http-client: Add network-error?. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Sun, 21 Apr 2024 09:44:10 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70494 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70494@debbugs.gnu.org Cc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 70494-submit@debbugs.gnu.org id=B70494.171369263624785 (code B ref 70494); Sun, 21 Apr 2024 09:44:10 +0000 Received: (at 70494) by debbugs.gnu.org; 21 Apr 2024 09:43:56 +0000 Received: from localhost ([127.0.0.1]:41791 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ryTjl-0006RL-Vd for submit@debbugs.gnu.org; Sun, 21 Apr 2024 05:43:55 -0400 Received: from mira.cbaines.net ([2a01:7e00:e000:2f8:fd4d:b5c7:13fb:3d27]:46331) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ryTj0-0006IW-0M for 70494@debbugs.gnu.org; Sun, 21 Apr 2024 05:43:09 -0400 Received: from localhost (unknown [IPv6:2a02:6b67:d93b:1:254c:b471:debc:14be]) by mira.cbaines.net (Postfix) with ESMTPSA id 675C627BBF8 for <70494@debbugs.gnu.org>; Sun, 21 Apr 2024 10:42:48 +0100 (BST) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id d4947319 for <70494@debbugs.gnu.org>; Sun, 21 Apr 2024 09:42:48 +0000 (UTC) From: Christopher Baines Date: Sun, 21 Apr 2024 10:42:36 +0100 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: <87bk632h36.fsf@cbaines.net> References: <87bk632h36.fsf@cbaines.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -3.38 X-Migadu-Scanner: mx11.migadu.com X-Spam-Score: -3.38 X-Migadu-Queue-Id: 307BA3AFE4 X-TUID: zaqZPFEYga3N Plus remove http-get-error? from network-error? as a http-get-error? doesn't indicate a network error. * guix/scripts/substitute.scm (system-error?, network-error?): Move from here. (process-substitution/fallback, process-substitution): Use http-get-error? with network-error?. * guix/http-client.scm: To here, and also don't use http-get-error?. Change-Id: I61ee9e5fbf90ebb76a34aa8b9ec8f5d74f8a3c54 --- guix/http-client.scm | 23 +++++++++++++++++++++++ guix/scripts/substitute.scm | 26 ++++---------------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/guix/http-client.scm b/guix/http-client.scm index 9138a627ac..024705e9ec 100644 --- a/guix/http-client.scm +++ b/guix/http-client.scm @@ -54,6 +54,8 @@ (define-module (guix http-client) http-get-error-reason http-get-error-headers + network-error? + http-fetch http-multiple-get @@ -75,6 +77,27 @@ (define-condition-type &http-get-error &error (reason http-get-error-reason) ;string (headers http-get-error-headers)) ;alist +(define kind-and-args-exception? + (exception-predicate &exception-with-kind-and-args)) + +(define (system-error? exception) + "Return true if EXCEPTION is a Guile 'system-error exception." + (and (kind-and-args-exception? exception) + (eq? 'system-error (exception-kind exception)))) + +(define network-error? + (let ((kind-and-args? (exception-predicate &exception-with-kind-and-args))) + (lambda (exception) + "Return true if EXCEPTION denotes a networking error." + (or (and (system-error? exception) + (let ((errno (system-error-errno + (cons 'system-error (exception-args exception))))) + (memv errno (list ECONNRESET ECONNABORTED ETIMEDOUT + ECONNREFUSED EHOSTUNREACH + ENOENT)))) ;for "file://" + (and (kind-and-args? exception) + (memq (exception-kind exception) + '(gnutls-error getaddrinfo-error))))))) (define* (http-fetch uri #:key port (text? #f) (buffered? #t) (open-connection guix:open-connection-for-uri) diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm index c2bc16085d..362d9fbe7a 100755 --- a/guix/scripts/substitute.scm +++ b/guix/scripts/substitute.scm @@ -577,26 +577,6 @@ (define* (download-nar narinfo destination (values expected (get-hash))))) -(define (system-error? exception) - "Return true if EXCEPTION is a Guile 'system-error exception." - (and (kind-and-args-exception? exception) - (eq? 'system-error (exception-kind exception)))) - -(define network-error? - (let ((kind-and-args? (exception-predicate &exception-with-kind-and-args))) - (lambda (exception) - "Return true if EXCEPTION denotes a networking error." - (or (and (system-error? exception) - (let ((errno (system-error-errno - (cons 'system-error (exception-args exception))))) - (memv errno (list ECONNRESET ECONNABORTED ETIMEDOUT - ECONNREFUSED EHOSTUNREACH - ENOENT)))) ;for "file://" - (and (kind-and-args? exception) - (memq (exception-kind exception) - '(gnutls-error getaddrinfo-error))) - (http-get-error? exception))))) - (define* (process-substitution/fallback narinfo destination #:key cache-urls acl deduplicate? print-build-trace? @@ -623,7 +603,8 @@ (define* (process-substitution/fallback narinfo destination (if (or (equivalent-narinfo? narinfo alternate) (valid-narinfo? alternate acl) (%allow-unauthenticated-substitutes?)) - (guard (c ((network-error? c) + (guard (c ((or (http-get-error? c) + (network-error? c)) (when (http-get-error? c) (warning (G_ "download from '~a' failed: ~a, ~s~%") (uri->string (http-get-error-uri c)) @@ -663,7 +644,8 @@ (define* (process-substitution store-item destination (let ((expected-hash actual-hash (guard - (c ((network-error? c) + (c ((or (http-get-error? c) + (network-error? c)) (when (http-get-error? c) (warning (G_ "download from '~a' failed: ~a, ~s~%") (uri->string (http-get-error-uri c)) -- 2.41.0