Merge pull request #107 from 18F/fix-validator-test

Fix validator_test hang on Solaris, Plan 9
This commit is contained in:
Jehiah Czebotar 2015-05-31 00:06:45 -04:00
commit 71b79baf33
3 changed files with 5 additions and 8 deletions

View File

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

View File

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

View File

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