Skip to content

Commit

Permalink
refactor file watch function to use fsnotify helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
jondavidnd1 committed Sep 25, 2024
1 parent 842aba5 commit 4ec48dc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions providers/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ func (f *File) Watch(cb func(event interface{}, err error)) error {
// Or has the real path of the file being watched changed?
//
// If either of the above are true, trigger the callback.
if (onWatchedFile && event.Op&(fsnotify.Write|fsnotify.Create) != 0) ||
if (onWatchedFile && (event.Has(fsnotify.Create) || event.Has(fsnotify.Write))) ||
(curPath != "" && curPath != realPath) {
realPath = curPath

// Trigger event.
cb(nil, nil)
} else if onWatchedFile && event.Op&fsnotify.Remove != 0 {
} else if onWatchedFile && event.Has(fsnotify.Remove) {
cb(nil, fmt.Errorf("file %s was removed", event.Name))
break loop
}
Expand Down

0 comments on commit 4ec48dc

Please sign in to comment.