From dd16a961252da12cd892e3c7748f50ce3793c919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Sun, 23 Jan 2022 14:51:54 +0100 Subject: [PATCH] canonicalize paths before normalization, fix symlink bug --- src/database/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/database/mod.rs b/src/database/mod.rs index 7b0c125..3bcdf5f 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -115,7 +115,7 @@ impl UpEndDatabase { let db = UpEndDatabase { pool, - vault_path: Arc::new(PathBuf::from(dirpath.as_ref())), + vault_path: Arc::new(dirpath.as_ref().canonicalize()?), db_path: Arc::new(upend_path), }; let connection = db.connection().unwrap(); @@ -250,7 +250,7 @@ impl UpEndConnection { } pub fn normalize_path(&self, path: &Path) -> Result { - Ok(path.strip_prefix(self.vault_path.as_path())?.to_path_buf()) + Ok(path.canonicalize()?.strip_prefix(self.vault_path.as_path())?.to_path_buf()) } pub fn retrieve_entry(&self, hash: Hash) -> Result> {