diff --git a/validator.go b/validator.go index 3e0373a4..4e3fe671 100644 --- a/validator.go +++ b/validator.go @@ -21,13 +21,10 @@ func NewUserMap(usersFile string, done <-chan bool, onUpdate func()) *UserMap { atomic.StorePointer(&um.m, unsafe.Pointer(&m)) if usersFile != "" { log.Printf("using authenticated emails file %s", usersFile) - started := WatchForUpdates(usersFile, done, func() { + WatchForUpdates(usersFile, done, func() { um.LoadAuthenticatedEmailsFile() onUpdate() }) - if started { - log.Printf("watching %s for updates", usersFile) - } um.LoadAuthenticatedEmailsFile() } return um diff --git a/watcher.go b/watcher.go index fa8f03fa..c34058b1 100644 --- a/watcher.go +++ b/watcher.go @@ -30,7 +30,7 @@ func WaitForReplacement(filename string, op fsnotify.Op, } } -func WatchForUpdates(filename string, done <-chan bool, action func()) bool { +func WatchForUpdates(filename string, done <-chan bool, action func()) { filename = filepath.Clean(filename) watcher, err := fsnotify.NewWatcher() if err != nil { @@ -65,5 +65,5 @@ func WatchForUpdates(filename string, done <-chan bool, action func()) bool { if err = watcher.Add(filename); err != nil { log.Fatal("failed to add ", filename, " to watcher: ", err) } - return true + log.Printf("watching %s for updates", filename) } diff --git a/watcher_unsupported.go b/watcher_unsupported.go index d65c8632..937f49bb 100644 --- a/watcher_unsupported.go +++ b/watcher_unsupported.go @@ -6,7 +6,7 @@ import ( "log" ) -func WatchForUpdates(filename string, done <-chan bool, action func()) bool { +func WatchForUpdates(filename string, done <-chan bool, action func()) { log.Printf("file watching not implemented on this platform") - return false + go func() { <-done }() }