fix: can't rewatch a directory that has been deleted once before (#1335)

Co-authored-by: sxyazi <sxyazi@gmail.com>
This commit is contained in:
leihaojun 2024-07-26 00:14:38 +08:00 committed by GitHub
parent df1f094a28
commit c086f2f34d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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