Read in tagger config on startup. Safeguard watcher shutdown

This commit is contained in:
Jan Eitzinger 2025-05-20 07:10:15 +02:00
parent 85f17c0fd8
commit 9abc206d1a
2 changed files with 5 additions and 1 deletions

View File

@ -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)
}

View File

@ -44,7 +44,9 @@ func AddListener(path string, l Listener) {
}
func FsWatcherShutdown() {
if w != nil {
w.Close()
}
}
func watchLoop(w *fsnotify.Watcher) {