[pbs-devel] [PATCH proxmox-backup 2/2] tools/subscription: ignore ENOENT for apt auth config removal

Dominik Csapak d.csapak at proxmox.com
Wed Mar 17 15:19:18 CET 2021


deleting a nonexistant file is hardly an error worth mentioning

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 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<String>, password: Option<String>) -> 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(())
 }
-- 
2.20.1






More information about the pbs-devel mailing list