From 2ebd53e612f044928c32525241d97d3927a59cff Mon Sep 17 00:00:00 2001 From: realaravinth Date: Sat, 4 Jun 2022 20:45:16 +0530 Subject: [PATCH] feat: impl interface to check if user exists for publiccode --- federate/publiccodeyml/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/federate/publiccodeyml/src/lib.rs b/federate/publiccodeyml/src/lib.rs index e1a4bdd..d76776c 100644 --- a/federate/publiccodeyml/src/lib.rs +++ b/federate/publiccodeyml/src/lib.rs @@ -152,6 +152,17 @@ impl Federate for PccFederate { } } + /// check if an user exists. + async fn user_exists(&self, username: &str, hostname: &str) -> Result { + let path = self.get_user_path(username, hostname, false).await?; + if path.exists() && path.is_dir() { + let user = path.join(USER_INFO_FILE); + Ok(user.exists() && user.is_file()) + } else { + Ok(false) + } + } + /// create user isntance async fn create_user(&self, f: &AddUser<'_>) -> Result<(), Self::Error> { let path = self.get_user_path(f.username, f.hostname, true).await?;