Skip to content

Commit

Permalink
not creating multiple watcher for single file path
Browse files Browse the repository at this point in the history
  • Loading branch information
prateek-narsinghani committed Apr 5, 2024
1 parent a45a466 commit 91c6bac
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions providers/file/file.go
Expand Up @@ -37,6 +37,11 @@ func (f *File) Read() (map[string]interface{}, error) {
// Watch watches the file and triggers a callback when it changes. It is a
// blocking function that internally spawns a goroutine to watch for changes.
func (f *File) Watch(cb func(event interface{}, err error)) error {
// If a watcher already exists, return an error.
if f.w != nil {
return errors.New("watcher already exists")
}

// Resolve symlinks and save the original path so that changes to symlinks
// can be detected.
realPath, err := filepath.EvalSymlinks(f.path)
Expand Down

0 comments on commit 91c6bac

Please sign in to comment.