From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 23BB8723CA for ; Tue, 25 May 2021 11:56:09 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0FBA52A88F for ; Tue, 25 May 2021 11:55:39 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id E367C2A883 for ; Tue, 25 May 2021 11:55:37 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id AE4A742B19 for ; Tue, 25 May 2021 11:55:37 +0200 (CEST) From: Thomas Lamprecht To: pbs-devel@lists.proxmox.com Date: Tue, 25 May 2021 11:55:32 +0200 Message-Id: <20210525095532.23752-1-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.007 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [apt.rs] Subject: [pbs-devel] applied: [PATCH backup] apt: fix removal of non-existant http-proxy config X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 May 2021 09:56:09 -0000 Signed-off-by: Thomas Lamprecht --- src/api2/node/apt.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/api2/node/apt.rs b/src/api2/node/apt.rs index 4bd911f4..35c9a79a 100644 --- a/src/api2/node/apt.rs +++ b/src/api2/node/apt.rs @@ -60,14 +60,14 @@ pub fn update_apt_proxy_config(proxy_config: Option<&ProxyConfig>) -> Result<(), if let Some(proxy_config) = proxy_config { let proxy = proxy_config.to_proxy_string()?; let data = format!("Acquire::http::Proxy \"{}\";\n", proxy); - replace_file(PROXY_CFG_FN, data.as_bytes(), CreateOptions::new())?; + replace_file(PROXY_CFG_FN, data.as_bytes(), CreateOptions::new()) } else { - std::fs::remove_file(PROXY_CFG_FN).map_err(|err| { - format_err!("failed to remove proxy config '{}' - {}", PROXY_CFG_FN, err) - })?; + match std::fs::remove_file(PROXY_CFG_FN) { + Ok(()) => Ok(()), + Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(()), + Err(err) => bail!("failed to remove proxy config '{}' - {}", PROXY_CFG_FN, err), + } } - - Ok(()) } fn read_and_update_proxy_config() -> Result, Error> { -- 2.29.2