mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
6a77193ae0
commit
2294f1daec
5 changed files with 30 additions and 11 deletions
|
|
@ -14,11 +14,18 @@ pub struct Partition {
|
|||
}
|
||||
|
||||
impl Partition {
|
||||
// Match mount types that do not reliably emit change notifications, or do not
|
||||
// update directory metadata on changes, and should be refreshed frequently.
|
||||
pub fn heuristic(&self) -> bool {
|
||||
// Match mount types that do not update directory mtime on changes,
|
||||
// and should be refreshed frequently.
|
||||
pub fn timeless(&self) -> bool {
|
||||
let b: &[u8] = self.fstype.as_ref().map_or(b"", |s| s.as_encoded_bytes());
|
||||
matches!(b, b"exfat" | b"fuse.rclone")
|
||||
matches!(b, b"exfat")
|
||||
}
|
||||
|
||||
// Match mount types that do not reliably emit change notifications,
|
||||
// and should be polled for changes.
|
||||
pub fn soundless(&self) -> bool {
|
||||
let b: &[u8] = self.fstype.as_ref().map_or(b"", |s| s.as_encoded_bytes());
|
||||
matches!(b, b"fuse.rclone")
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
|
|
|
|||
|
|
@ -31,14 +31,26 @@ impl Partitions {
|
|||
self.inner.iter().find(|p| p.rdev == Some(dev))
|
||||
}
|
||||
|
||||
pub fn heuristic(&self, _cha: Cha) -> bool {
|
||||
pub fn timeless(&self, _cha: Cha) -> bool {
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
{
|
||||
self.by_dev(_cha.dev).is_some_and(|p| p.heuristic())
|
||||
self.by_dev(_cha.dev).is_some_and(|p| p.timeless())
|
||||
}
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
|
||||
{
|
||||
// For now, assume other targets update directory stat data correctly
|
||||
// For now, assume other targets update directory mtime correctly
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn soundless(&self, _cha: Cha) -> bool {
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
{
|
||||
self.by_dev(_cha.dev).is_some_and(|p| p.soundless())
|
||||
}
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
|
||||
{
|
||||
// For now, assume other targets emit change notifications correctly
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ impl VfsFiles for Files {
|
|||
use std::io::ErrorKind;
|
||||
match Cha::from_url(dir).await {
|
||||
Ok(c) if !c.is_dir() => FilesOp::issue_error(dir, ErrorKind::NotADirectory).await,
|
||||
Ok(c) if c.hits(cha) && !PARTITIONS.read().heuristic(cha) => {}
|
||||
Ok(c) if c.hits(cha) && !PARTITIONS.read().timeless(cha) => {}
|
||||
Ok(c) => return Some(c),
|
||||
Err(e) => FilesOp::issue_error(dir, e).await,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,13 +74,13 @@ impl Local {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn heuristic(path: &Path) -> bool {
|
||||
pub(crate) fn soundless(path: &Path) -> bool {
|
||||
if cfg!(target_os = "netbsd") || yazi_adapter::WSL.get() {
|
||||
return true;
|
||||
}
|
||||
|
||||
let Ok(meta) = path.metadata() else { return true };
|
||||
PARTITIONS.read().heuristic(Cha::new(path.file_name().unwrap_or_default(), meta))
|
||||
PARTITIONS.read().soundless(Cha::new(path.file_name().unwrap_or_default(), meta))
|
||||
}
|
||||
|
||||
async fn changed(rx: UnboundedReceiver<UrlBuf>) {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ impl<'a> Watchee<'a> {
|
|||
{
|
||||
let url = url.into();
|
||||
if let Some(path) = url.as_local() {
|
||||
let b = Local::heuristic(path);
|
||||
let b = Local::soundless(path);
|
||||
Self::Local(url, b)
|
||||
} else {
|
||||
Self::Remote(url)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue