mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
fix: record the follow state of symlink correctly (#3195)
This commit is contained in:
parent
e9742cb809
commit
c0c0877d42
3 changed files with 20 additions and 18 deletions
|
|
@ -66,11 +66,9 @@ impl Cha {
|
||||||
let mut retain = cha.kind & (ChaKind::HIDDEN | ChaKind::SYSTEM);
|
let mut retain = cha.kind & (ChaKind::HIDDEN | ChaKind::SYSTEM);
|
||||||
|
|
||||||
if cha.is_link() {
|
if cha.is_link() {
|
||||||
|
retain |= ChaKind::FOLLOW;
|
||||||
cha = provider::metadata(url).await.unwrap_or(cha);
|
cha = provider::metadata(url).await.unwrap_or(cha);
|
||||||
}
|
}
|
||||||
if cha.is_link() {
|
|
||||||
retain |= ChaKind::ORPHAN;
|
|
||||||
}
|
|
||||||
|
|
||||||
cha.attach(retain)
|
cha.attach(retain)
|
||||||
}
|
}
|
||||||
|
|
@ -150,7 +148,17 @@ impl Cha {
|
||||||
|
|
||||||
impl Cha {
|
impl Cha {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn is_hidden(&self) -> bool {
|
pub fn is_link(self) -> bool {
|
||||||
|
self.kind.contains(ChaKind::FOLLOW) || *self.mode == ChaType::Link
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn is_orphan(self) -> bool {
|
||||||
|
*self.mode == ChaType::Link && self.kind.contains(ChaKind::FOLLOW)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub const fn is_hidden(self) -> bool {
|
||||||
win_either!(
|
win_either!(
|
||||||
self.kind.contains(ChaKind::HIDDEN) || self.kind.contains(ChaKind::SYSTEM),
|
self.kind.contains(ChaKind::HIDDEN) || self.kind.contains(ChaKind::SYSTEM),
|
||||||
self.kind.contains(ChaKind::HIDDEN)
|
self.kind.contains(ChaKind::HIDDEN)
|
||||||
|
|
@ -158,12 +166,9 @@ impl Cha {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn is_orphan(&self) -> bool { self.kind.contains(ChaKind::ORPHAN) }
|
pub const fn is_dummy(self) -> bool { self.kind.contains(ChaKind::DUMMY) }
|
||||||
|
|
||||||
#[inline]
|
pub fn atime_dur(self) -> anyhow::Result<Duration> {
|
||||||
pub const fn is_dummy(&self) -> bool { self.kind.contains(ChaKind::DUMMY) }
|
|
||||||
|
|
||||||
pub fn atime_dur(&self) -> anyhow::Result<Duration> {
|
|
||||||
if let Some(atime) = self.atime {
|
if let Some(atime) = self.atime {
|
||||||
Ok(atime.duration_since(UNIX_EPOCH)?)
|
Ok(atime.duration_since(UNIX_EPOCH)?)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -171,7 +176,7 @@ impl Cha {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mtime_dur(&self) -> anyhow::Result<Duration> {
|
pub fn mtime_dur(self) -> anyhow::Result<Duration> {
|
||||||
if let Some(mtime) = self.mtime {
|
if let Some(mtime) = self.mtime {
|
||||||
Ok(mtime.duration_since(UNIX_EPOCH)?)
|
Ok(mtime.duration_since(UNIX_EPOCH)?)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -179,7 +184,7 @@ impl Cha {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn btime_dur(&self) -> anyhow::Result<Duration> {
|
pub fn btime_dur(self) -> anyhow::Result<Duration> {
|
||||||
if let Some(btime) = self.btime {
|
if let Some(btime) = self.btime {
|
||||||
Ok(btime.duration_since(UNIX_EPOCH)?)
|
Ok(btime.duration_since(UNIX_EPOCH)?)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -187,7 +192,7 @@ impl Cha {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ctime_dur(&self) -> anyhow::Result<Duration> {
|
pub fn ctime_dur(self) -> anyhow::Result<Duration> {
|
||||||
if let Some(ctime) = self.ctime {
|
if let Some(ctime) = self.ctime {
|
||||||
Ok(ctime.duration_since(UNIX_EPOCH)?)
|
Ok(ctime.duration_since(UNIX_EPOCH)?)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ use bitflags::bitflags;
|
||||||
bitflags! {
|
bitflags! {
|
||||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||||
pub struct ChaKind: u8 {
|
pub struct ChaKind: u8 {
|
||||||
const HIDDEN = 0b0000_0001;
|
const FOLLOW = 0b0000_0001;
|
||||||
const SYSTEM = 0b0000_0010;
|
const HIDDEN = 0b0000_0010;
|
||||||
const ORPHAN = 0b0000_0100;
|
const SYSTEM = 0b0000_0100;
|
||||||
const DUMMY = 0b0000_1000;
|
const DUMMY = 0b0000_1000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,9 +63,6 @@ impl ChaType {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_dir(self) -> bool { self == Self::Dir }
|
pub fn is_dir(self) -> bool { self == Self::Dir }
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn is_link(self) -> bool { self == Self::Link }
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_block(self) -> bool { self == Self::Block }
|
pub fn is_block(self) -> bool { self == Self::Block }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue