Skip to content

Commit

Permalink
fix: ensure that LINK and ORPHAN cannot coexist
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Jan 15, 2024
1 parent a1c963a commit 8533445
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 0 additions & 2 deletions yazi-shared/src/fs/cha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ impl From<Metadata> for Cha {
let mut ck = ChaKind::empty();
if m.is_dir() {
ck |= ChaKind::DIR;
} else if m.is_symlink() {
ck |= ChaKind::LINK;
}

#[cfg(unix)]
Expand Down
3 changes: 2 additions & 1 deletion yazi-shared/src/fs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ impl File {
let (is_link, mut link_to) = (meta.is_symlink(), None);

if is_link {
ck |= ChaKind::LINK;
meta = fs::metadata(&url).await.unwrap_or(meta);
link_to = fs::read_link(&url).await.map(Url::from).ok();
}

if is_link && meta.is_symlink() {
ck |= ChaKind::ORPHAN;
} else if is_link {
ck |= ChaKind::LINK;
}

if url.is_hidden() {
Expand Down

0 comments on commit 8533445

Please sign in to comment.