about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/indieauth/backend/fs.rs19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/indieauth/backend/fs.rs b/src/indieauth/backend/fs.rs
index 5e97ae5..ce519da 100644
--- a/src/indieauth/backend/fs.rs
+++ b/src/indieauth/backend/fs.rs
@@ -123,6 +123,7 @@ impl FileBackend {
     }
 
     #[inline]
+    #[tracing::instrument]
     fn url_to_dir(url: &url::Url) -> String {
         let host = url.host_str().unwrap();
         let port = url.port()
@@ -188,6 +189,14 @@ impl FileBackend {
 #[async_trait]
 impl AuthBackend for FileBackend {
     async fn new(path: &'_ url::Url) -> Result<Self> {
+        let orig_path = path;
+        let mut path = orig_path.clone();
+        if path.host_str() == Some(".") {
+            let base = url::Url::from_directory_path(std::env::current_dir()?).unwrap();
+
+            path = base.join(&format!(".{}", path.path())).unwrap();
+        }
+        tracing::debug!("Initializing File auth backend: {} -> {}", orig_path, path.path());
         Ok(Self {
             path: std::path::PathBuf::from(path.path())
         })
@@ -396,12 +405,14 @@ impl AuthBackend for FileBackend {
         todo!()
     }
 
+    #[tracing::instrument(skip(self))]
     async fn list_user_credential_types(&self, website: &url::Url) -> Result<Vec<EnrolledCredential>> {
         let mut creds = vec![];
-
-        match tokio::fs::metadata(self.path
-                                  .join(FileBackend::url_to_dir(website))
-                                  .join("password"))
+        let password_file = self.path
+            .join(FileBackend::url_to_dir(website))
+            .join("password");
+        tracing::debug!("Password file for {}: {}", website, password_file.display());
+        match tokio::fs::metadata(password_file)
             .await
         {
             Ok(_) => creds.push(EnrolledCredential::Password),