fix: ensure that LINK and ORPHAN cannot coexist

This commit is contained in:
sxyazi 2024-01-15 20:31:31 +08:00
parent a1c963accc
commit 85334457f3
No known key found for this signature in database
2 changed files with 2 additions and 3 deletions

View File

@ -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)]

View File

@ -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() {