Преглед изворни кода

fix: close superseded file watcher before re-registering

When WatchFileWrite is called again for the same path, stop the prior
watcher by closing its done channel so StopFileWatch and replacement
registrations cannot leave duplicate callbacks active.

Co-authored-by: Cursor <cursoragent@cursor.com>
jamesread пре 1 дан
родитељ
комит
0cbe18b17b
1 измењених фајлова са 3 додато и 0 уклоњено
  1. 3 0
      service/internal/filehelper/file_change_notify.go

+ 3 - 0
service/internal/filehelper/file_change_notify.go

@@ -112,6 +112,9 @@ func registerFileWatch(watchKey string) chan struct{} {
 
 	done := make(chan struct{})
 	fileWatchMu.Lock()
+	if previous, ok := fileWatchStops[watchKey]; ok {
+		close(previous)
+	}
 	fileWatchStops[watchKey] = done
 	fileWatchMu.Unlock()
 	return done