diff --git a/filenotify/poller.go b/filenotify/poller.go index 0d92afd..5261085 100644 --- a/filenotify/poller.go +++ b/filenotify/poller.go @@ -118,8 +118,6 @@ func (w *filePoller) Close() error { w.remove(name) delete(w.watches, name) } - close(w.events) - close(w.errors) return nil } @@ -146,6 +144,7 @@ func (w *filePoller) sendErr(e error, chClose <-chan struct{}) error { // watch is responsible for polling the specified file for changes // upon finding changes to a file or errors, sendEvent/sendErr is called func (w *filePoller) watch(f *os.File, lastFi os.FileInfo, chClose chan struct{}) { + defer f.Close() for { time.Sleep(watchWaitTime) select { diff --git a/filenotify/poller_test.go b/filenotify/poller_test.go index 0715c25..4f50262 100644 --- a/filenotify/poller_test.go +++ b/filenotify/poller_test.go @@ -93,24 +93,6 @@ func TestPollerClose(t *testing.T) { t.Fatal(err) } - select { - case _, open := <-w.Events(): - if open { - t.Fatal("event chan should be closed") - } - default: - t.Fatal("event chan should be closed") - } - - select { - case _, open := <-w.Errors(): - if open { - t.Fatal("errors chan should be closed") - } - default: - t.Fatal("errors chan should be closed") - } - f, err := ioutil.TempFile("", "asdf") if err != nil { t.Fatal(err)