Просмотр исходного кода

fix: bugfix to resolve absolute paths that are not symlinks

Daniel Lang 1 год назад
Родитель
Сommit
7eb72bd15c
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      src/fs/file.rs

+ 1 - 1
src/fs/file.rs

@@ -344,7 +344,7 @@ impl<'dir> File<'dir> {
     pub fn absolute_path(&self) -> Option<&PathBuf> {
     pub fn absolute_path(&self) -> Option<&PathBuf> {
         self.absolute_path
         self.absolute_path
             .get_or_init(|| {
             .get_or_init(|| {
-                if self.link_target().is_broken() {
+                if self.is_link() && self.link_target().is_broken() {
                     // workaround for broken symlinks to get absolute path for parent and then
                     // workaround for broken symlinks to get absolute path for parent and then
                     // append name of file; std::fs::canonicalize requires all path components
                     // append name of file; std::fs::canonicalize requires all path components
                     // (including the last one) to exist
                     // (including the last one) to exist