mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
fix: fallback to PollWatcher instead of panicking when RecommendedWatcher initialization fails (#3281)
This commit is contained in:
parent
641bc6ff47
commit
c11ed02760
1 changed files with 11 additions and 4 deletions
|
|
@ -5,6 +5,7 @@ use hashbrown::HashSet;
|
||||||
use notify::{PollWatcher, RecommendedWatcher, RecursiveMode, Watcher};
|
use notify::{PollWatcher, RecommendedWatcher, RecursiveMode, Watcher};
|
||||||
use tokio::{pin, sync::mpsc::{self, UnboundedReceiver}};
|
use tokio::{pin, sync::mpsc::{self, UnboundedReceiver}};
|
||||||
use tokio_stream::{StreamExt, wrappers::UnboundedReceiverStream};
|
use tokio_stream::{StreamExt, wrappers::UnboundedReceiverStream};
|
||||||
|
use tracing::error;
|
||||||
use yazi_fs::{File, FilesOp, provider};
|
use yazi_fs::{File, FilesOp, provider};
|
||||||
use yazi_shared::url::{UrlBuf, UrlLike};
|
use yazi_shared::url::{UrlBuf, UrlLike};
|
||||||
use yazi_vfs::VfsFile;
|
use yazi_vfs::VfsFile;
|
||||||
|
|
@ -26,10 +27,16 @@ impl Local {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Self(if yazi_adapter::WSL.get() || cfg!(target_os = "netbsd") {
|
if cfg!(target_os = "netbsd") || yazi_adapter::WSL.get() {
|
||||||
Box::new(PollWatcher::new(handler, config).unwrap())
|
return Self(Box::new(PollWatcher::new(handler, config).unwrap()));
|
||||||
} else {
|
}
|
||||||
Box::new(RecommendedWatcher::new(handler, config).unwrap())
|
|
||||||
|
Self(match RecommendedWatcher::new(handler.clone(), config) {
|
||||||
|
Ok(watcher) => Box::new(watcher),
|
||||||
|
Err(e) => {
|
||||||
|
error!("Falling back to PollWatcher due to RecommendedWatcher init failure: {e:?}");
|
||||||
|
Box::new(PollWatcher::new(handler, config).unwrap())
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue