Skip to content

Commit 2c112c1

Browse files
committed
Handle missing directory watch targets
1 parent 54e5c38 commit 2c112c1

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

src/engine.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,10 @@ fn resolve_watch_registrations(
572572
.parent()
573573
.ok_or_else(|| anyhow!("watch target '{}' has no parent", target.path.display()))?;
574574
if immediate_parent.exists() {
575+
let recursive = target.path.extension().is_none();
575576
return Ok(vec![CompiledWatchTarget {
576577
path: immediate_parent.to_path_buf(),
577-
recursive: false,
578+
recursive,
578579
}]);
579580
}
580581

@@ -779,6 +780,29 @@ mod tests {
779780
);
780781
}
781782

783+
#[test]
784+
fn resolve_watch_registration_uses_recursive_parent_for_missing_directory_like_target() {
785+
let dir = tempdir().expect("tempdir");
786+
let target = dir.path().join("content");
787+
788+
let registrations = resolve_watch_registrations(
789+
&CompiledWatchTarget {
790+
path: target,
791+
recursive: false,
792+
},
793+
WatcherKind::Native,
794+
)
795+
.expect("resolve watch registration");
796+
797+
assert_eq!(
798+
registrations,
799+
vec![CompiledWatchTarget {
800+
path: dir.path().to_path_buf(),
801+
recursive: true,
802+
}]
803+
);
804+
}
805+
782806
#[test]
783807
fn resolve_watch_registration_climbs_recursively_when_parent_is_missing() {
784808
let dir = tempdir().expect("tempdir");

0 commit comments

Comments
 (0)