fix(watch): stop swallowing SetRecursive errors via nolint

Split SetRecursive into the existing per-GOOS watcher files instead of
a runtime check + nolint: the non-Windows stub never calls the
always-failing SetRecursive, and Windows failures now propagate as a
real error instead of silently downgrading to non-recursive.

Addresses review from thaJeztah on #14164.

Signed-off-by: Guillaume Lours <[email protected]>
This commit is contained in:
Guillaume Lours
2026-09-02 15:07:08 +02:00
committed by Guillaume Lours
parent 70e17bfc66
commit 05066c2418
3 changed files with 16 additions and 5 deletions
+4 -5
View File
@@ -309,11 +309,10 @@ func newWatcher(paths []string) (Notify, error) {
}
MaybeIncreaseBufferSize(fsw)
// SetRecursive only succeeds on Windows; every other platform returns
// "Not supported" and the non-recursive fallback below is taken. On a
// single GOOS staticcheck proves the comparison constant (SA4023).
err = fsw.SetRecursive() //nolint:staticcheck
isWatcherRecursive := err == nil //nolint:staticcheck
isWatcherRecursive, err := setRecursive(fsw)
if err != nil {
return nil, err
}
wrappedEvents := make(chan FileEvent)
notifyList := make(map[string]bool, len(paths))
+5
View File
@@ -23,3 +23,8 @@ import "github.com/tilt-dev/fsnotify"
func MaybeIncreaseBufferSize(w *fsnotify.Watcher) {
// Not needed on non-windows
}
func setRecursive(_ *fsnotify.Watcher) (bool, error) {
// SetRecursive is only supported on Windows.
return false, nil
}
+7
View File
@@ -33,3 +33,10 @@ import (
func MaybeIncreaseBufferSize(w *fsnotify.Watcher) {
w.SetBufferSize(DesiredWindowsBufferSize())
}
func setRecursive(w *fsnotify.Watcher) (bool, error) {
if err := w.SetRecursive(); err != nil {
return false, err
}
return true, nil
}