Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
linux: Don't watch parent directory when target path already exists (#21854)
Cole Miller543a3ef5e453
diff --git a/Cargo.lock b/Cargo.lockindex d8950b856c5..def04c674e5 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -4787,6 +4787,7 @@ dependencies = ["git2","gpui","libc",+ "log","notify","objc","parking_lot",diff --git a/crates/fs/Cargo.toml b/crates/fs/Cargo.tomlindex 7a1cfaeaa59..fe145a6be58 100644--- a/crates/fs/Cargo.toml+++ b/crates/fs/Cargo.toml@@ -21,6 +21,7 @@ git.workspace = truegit2.workspace = truegpui.workspace = truelibc.workspace = true+log.workspace = trueparking_lot.workspace = truepaths.workspace = truerope.workspace = truediff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rsindex 17571de76b7..0706c0e41cc 100644--- a/crates/fs/src/fs.rs+++ b/crates/fs/src/fs.rs@@ -695,10 +695,13 @@ impl Fs for RealFs {let pending_paths: Arc<Mutex<Vec<PathEvent>>> = Default::default();let watcher = Arc::new(linux_watcher::LinuxWatcher::new(tx, pending_paths.clone()));- watcher.add(&path).ok(); // Ignore "file doesn't exist error" and rely on parent watcher.- if let Some(parent) = path.parent() {- // watch the parent dir so we can tell when settings.json is created- watcher.add(parent).log_err();+ if watcher.add(path).is_err() {+ // If the path doesn't exist yet (e.g. settings.json), watch the parent dir to learn when it's created.+ if let Some(parent) = path.parent() {+ if let Err(e) = watcher.add(parent) {+ log::warn!("Failed to watch: {e}");+ }+ }}// Check if path is a symlink and follow the target parent