mirror of
https://github.com/docker/compose.git
synced 2026-10-12 02:13:08 +00:00
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:
committed by
Guillaume Lours
parent
70e17bfc66
commit
05066c2418
@@ -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))
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user