From 5057ba2e1c22fd0d87af4023a4ed1b5c987290bb Mon Sep 17 00:00:00 2001 From: James Read Date: Sun, 21 Apr 2024 20:51:49 +0100 Subject: [PATCH] bugfix: Start filewatcher on different goroutines (#286) --- internal/entityfiles/entityfiles.go | 4 +++- internal/onfileindir/fileindir.go | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/entityfiles/entityfiles.go b/internal/entityfiles/entityfiles.go index b28abeb..35b26e3 100644 --- a/internal/entityfiles/entityfiles.go +++ b/internal/entityfiles/entityfiles.go @@ -35,9 +35,11 @@ func SetupEntityFileWatchers(cfg *config.Config) { }).Debugf("Adding config dir to entity file path") } - filehelper.WatchFileWrite(p, func(filename string) { + go filehelper.WatchFileWrite(p, func(filename string) { loadEntityFile(p, ef.Name) }) + + loadEntityFile(p, ef.Name) } } diff --git a/internal/onfileindir/fileindir.go b/internal/onfileindir/fileindir.go index ccbefac..fbcbcee 100644 --- a/internal/onfileindir/fileindir.go +++ b/internal/onfileindir/fileindir.go @@ -10,13 +10,13 @@ import ( func WatchFilesInDirectory(cfg *config.Config, ex *executor.Executor) { for _, action := range cfg.Actions { for _, dirname := range action.ExecOnFileChangedInDir { - filehelper.WatchDirectoryWrite(dirname, func(filename string) { + go filehelper.WatchDirectoryWrite(dirname, func(filename string) { scheduleExec(action, cfg, ex, filename) }) } for _, dirname := range action.ExecOnFileCreatedInDir { - filehelper.WatchDirectoryCreate(dirname, func(filename string) { + go filehelper.WatchDirectoryCreate(dirname, func(filename string) { scheduleExec(action, cfg, ex, filename) }) }