Skip to content

Commit

Permalink
fix: ignoring events from excluded-dirs sub path
Browse files Browse the repository at this point in the history
  • Loading branch information
nxtcoder17 committed Dec 31, 2024
1 parent 76d04c5 commit 70c2485
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/watcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ func (f fsnWatcher) ignoreEvent(event fsnotify.Event) (ignore bool, reason strin
return true, "event is from a special file from vim/neovim which ends in ~"
}

for k := range f.ExcludeDirs {
if strings.HasPrefix(event.Name, k) {
return true, "event is generating from an excluded path"
}
}

for _, suffix := range f.IgnoreSuffixes {
if strings.HasSuffix(event.Name, suffix) {
f.Logger.Debug("file is ignored", "file", event.Name)
Expand Down Expand Up @@ -152,7 +158,9 @@ func (f *fsnWatcher) RecursiveAdd(dirs ...string) error {

fi, err := os.Lstat(dir)
if err != nil {
return err
continue
// INFO: instead of returning and error, seems like ignore is a better choice
// return err
}

if !fi.IsDir() {
Expand Down

0 comments on commit 70c2485

Please sign in to comment.