prevent data race in file watcher goroutine

This commit is contained in:
ionutboangiu
2025-02-26 15:48:18 +02:00
committed by Dan Christian Bogos
parent 508d27e836
commit c4642fa30b

View File

@@ -49,7 +49,7 @@ func watchDir(dirPath string, f func(itmPath, itmID string) error,
case ev := <-watcher.Events:
if ev.Op&fsnotify.Create == fsnotify.Create {
go func() { //Enable async processing here so we can simultaneously process files
if err = f(filepath.Dir(ev.Name), filepath.Base(ev.Name)); err != nil {
if err := f(filepath.Dir(ev.Name), filepath.Base(ev.Name)); err != nil {
utils.Logger.Warning(fmt.Sprintf("<%s> processing path <%s>, error: <%s>",
sysID, ev.Name, err.Error()))
}