From caf76ec592d7f5eda21997771deb717891b602ae Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Wed, 17 Mar 2021 15:19:18 +0100 Subject: [PATCH] tools/subscription: ignore ENOENT for apt auth config removal deleting a nonexistant file is hardly an error worth mentioning Signed-off-by: Dominik Csapak --- src/tools/subscription.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tools/subscription.rs b/src/tools/subscription.rs index 07c6b40f..9b9534ac 100644 --- a/src/tools/subscription.rs +++ b/src/tools/subscription.rs @@ -318,8 +318,11 @@ pub fn update_apt_auth(key: Option, password: Option) -> Result< replace_file(auth_conf, conf.as_bytes(), file_opts) .map_err(|e| format_err!("Error saving apt auth config - {}", e))?; } - _ => nix::unistd::unlink(auth_conf) - .map_err(|e| format_err!("Error clearing apt auth config - {}", e))?, + _ => match nix::unistd::unlink(auth_conf) { + Ok(()) => Ok(()), + Err(nix::Error::Sys(nix::errno::Errno::ENOENT)) => Ok(()), // ignore not existing + Err(err) => Err(err), + }.map_err(|e| format_err!("Error clearing apt auth config - {}", e))?, } Ok(()) }