From e9c2638f90784d92f32357fcd274e2ac956160ef Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Tue, 25 May 2021 11:54:46 +0200 Subject: [PATCH] apt: fix removal of non-existant http-proxy config 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> {