From 9abc206d1af849d86e737c5219f6ab248e830e50 Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Tue, 20 May 2025 07:10:15 +0200 Subject: [PATCH] Read in tagger config on startup. Safeguard watcher shutdown --- internal/tagger/detectApp.go | 2 ++ internal/util/fswatcher.go | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/tagger/detectApp.go b/internal/tagger/detectApp.go index 621e20c..d3d797d 100644 --- a/internal/tagger/detectApp.go +++ b/internal/tagger/detectApp.go @@ -51,6 +51,7 @@ func (t *AppTagger) EventMatch(s string) bool { return strings.Contains(s, "apps") } +// FIXME: Only process the file that caused the event func (t *AppTagger) EventCallback() { files, err := os.ReadDir(appPath) if err != nil { @@ -85,6 +86,7 @@ func (t *AppTagger) Register() error { } if util.CheckFileExists(appPath) { + t.EventCallback() log.Infof("Setup file watch for %s", appPath) util.AddListener(appPath, t) } diff --git a/internal/util/fswatcher.go b/internal/util/fswatcher.go index aaf3372..5d13462 100644 --- a/internal/util/fswatcher.go +++ b/internal/util/fswatcher.go @@ -44,7 +44,9 @@ func AddListener(path string, l Listener) { } func FsWatcherShutdown() { - w.Close() + if w != nil { + w.Close() + } } func watchLoop(w *fsnotify.Watcher) {