[pbs-devel] applied: [PATCH backup] apt: fix removal of non-existant http-proxy config
Thomas Lamprecht
t.lamprecht at proxmox.com
Tue May 25 11:55:32 CEST 2021
Signed-off-by: Thomas Lamprecht <t.lamprecht at 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
More information about the pbs-devel
mailing list