From d3066683da80496ee960e3e6a68a2c7f5a99f4ef Mon Sep 17 00:00:00 2001 From: realaravinth Date: Sat, 4 Jun 2022 21:30:14 +0530 Subject: [PATCH] feat: impl repository_exists for publiccodeyml --- federate/publiccodeyml/src/lib.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/federate/publiccodeyml/src/lib.rs b/federate/publiccodeyml/src/lib.rs index d76776c..e713cca 100644 --- a/federate/publiccodeyml/src/lib.rs +++ b/federate/publiccodeyml/src/lib.rs @@ -179,6 +179,22 @@ impl Federate for PccFederate { self.write_util(&publiccode, &path).await } + /// check if a repository exists. + async fn repository_exists( + &self, + name: &str, + owner: &str, + hostname: &str, + ) -> Result { + let path = self.get_repo_path(name, owner, hostname, false).await?; + if path.exists() && path.is_dir() { + let repo = path.join(REPO_INFO_FILE); + Ok(repo.exists() && repo.is_file()) + } else { + Ok(false) + } + } + /// delete user async fn delete_user(&self, username: &str, hostname: &str) -> Result<(), Self::Error> { let path = self.get_user_path(username, hostname, false).await?;