Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions realize/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ func (w *filePoller) Add(name string) error {
return errPollerClosed
}

if w.watches == nil {
w.watches = make(map[string]chan struct{})
} else if _, exists := w.watches[name]; exists {
return fmt.Errorf("watch exists")
}

f, err := os.Open(name)
if err != nil {
return err
Expand All @@ -146,12 +152,6 @@ func (w *filePoller) Add(name string) error {
return err
}

if w.watches == nil {
w.watches = make(map[string]chan struct{})
}
if _, exists := w.watches[name]; exists {
return fmt.Errorf("watch exists")
}
chClose := make(chan struct{})
w.watches[name] = chClose
go w.watch(f, fi, chClose)
Expand Down