From c086f2f34d8aa33249ae23b535b329c9e97aed0f Mon Sep 17 00:00:00 2001 From: leihaojun <2952479063@qq.com> Date: Fri, 26 Jul 2024 00:14:38 +0800 Subject: [PATCH] fix: can't rewatch a directory that has been deleted once before (#1335) Co-authored-by: sxyazi --- yazi-core/src/manager/watcher.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/yazi-core/src/manager/watcher.rs b/yazi-core/src/manager/watcher.rs index 53449f3a..5e6048c1 100644 --- a/yazi-core/src/manager/watcher.rs +++ b/yazi-core/src/manager/watcher.rs @@ -72,7 +72,14 @@ impl Watcher { (old.difference(new).cloned().collect(), new.difference(old).cloned().collect()) }; - to_unwatch.retain(|u| watcher.unwatch(u).is_ok()); + to_unwatch.retain(|u| match watcher.unwatch(u) { + Ok(_) => true, + Err(e) if matches!(e.kind, notify::ErrorKind::WatchNotFound) => true, + Err(e) => { + error!("Unwatch failed: {e:?}"); + false + } + }); to_watch.retain(|u| watcher.watch(u, RecursiveMode::NonRecursive).is_ok()); {