public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] applied: [PATCH backup] apt: fix removal of non-existant http-proxy config
Date: Tue, 25 May 2021 11:55:32 +0200	[thread overview]
Message-ID: <20210525095532.23752-1-t.lamprecht@proxmox.com> (raw)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 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<Option<ProxyConfig>, Error> {
-- 
2.29.2





                 reply	other threads:[~2021-05-25  9:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210525095532.23752-1-t.lamprecht@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal