From efd49e7f3d80d7ecc9299bd06cd17238220e9dcc Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Fri, 13 Sep 2024 06:00:08 +0530 Subject: [PATCH] Handle symlinked database files correctly --- CHANGELOG.md | 1 + src/db/mod.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b0105e3..39635319 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 `$__fish_data_dir/functions/cd.fish`. This should minimize the chances of an infinite loop when aliasing `cd=z`. - Symlinks not getting added to the database when `$_ZO_RESOLVE_SYMLINKS=0`. +- Handle symlinked database files correctly. ## [0.9.4] - 2024-02-21 diff --git a/src/db/mod.rs b/src/db/mod.rs index 171b4d79..1eae1a92 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -33,6 +33,7 @@ impl Database { pub fn open_dir(data_dir: impl AsRef) -> Result { let data_dir = data_dir.as_ref(); let path = data_dir.join("db.zo"); + let path = fs::canonicalize(&path).unwrap_or(path); match fs::read(&path) { Ok(bytes) => Self::try_new(path, bytes, |bytes| Self::deserialize(bytes), false),