apt: fix removal of non-existant http-proxy config
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
338c545f85
commit
e9c2638f90
@ -60,14 +60,14 @@ pub fn update_apt_proxy_config(proxy_config: Option<&ProxyConfig>) -> Result<(),
|
|||||||
if let Some(proxy_config) = proxy_config {
|
if let Some(proxy_config) = proxy_config {
|
||||||
let proxy = proxy_config.to_proxy_string()?;
|
let proxy = proxy_config.to_proxy_string()?;
|
||||||
let data = format!("Acquire::http::Proxy \"{}\";\n", proxy);
|
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 {
|
} else {
|
||||||
std::fs::remove_file(PROXY_CFG_FN).map_err(|err| {
|
match std::fs::remove_file(PROXY_CFG_FN) {
|
||||||
format_err!("failed to remove proxy config '{}' - {}", PROXY_CFG_FN, err)
|
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> {
|
fn read_and_update_proxy_config() -> Result<Option<ProxyConfig>, Error> {
|
||||||
|
Loading…
Reference in New Issue
Block a user