public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] applied: [PATCH backup] apt: fix removal of non-existant http-proxy config
@ 2021-05-25  9:55 Thomas Lamprecht
  0 siblings, 0 replies; only message in thread
From: Thomas Lamprecht @ 2021-05-25  9:55 UTC (permalink / raw)
  To: pbs-devel

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





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-25  9:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-25  9:55 [pbs-devel] applied: [PATCH backup] apt: fix removal of non-existant http-proxy config Thomas Lamprecht

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