Skip to content

Commit

Permalink
Potential fix for #121
Browse files Browse the repository at this point in the history
  • Loading branch information
qknight committed Jul 12, 2023
1 parent f5989f8 commit 5f1c168
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"regexp"
"strings"
"sync"
"syscall"
"time"
)

Expand Down Expand Up @@ -495,29 +496,35 @@ func (w *Watcher) retrieveFileList() map[string]os.FileInfo {
if recursive {
list, err = w.listRecursive(name)
if err != nil {
if os.IsNotExist(err) {
w.mu.Unlock()
if name == err.(*os.PathError).Path {
w.Error <- ErrWatchedFileDeleted
w.RemoveRecursive(name)
e, ok := err.(syscall.Errno)
if ok && e.Is(err) {
if os.IsNotExist(err) {
w.mu.Unlock()
if name == err.(*os.PathError).Path {
w.Error <- ErrWatchedFileDeleted
w.RemoveRecursive(name)
}
w.mu.Lock()
} else {
w.Error <- err
}
w.mu.Lock()
} else {
w.Error <- err
}
}
} else {
list, err = w.list(name)
if err != nil {
if os.IsNotExist(err) {
w.mu.Unlock()
if name == err.(*os.PathError).Path {
w.Error <- ErrWatchedFileDeleted
w.Remove(name)
e, ok := err.(syscall.Errno)
if ok && e.Is(err) {
if os.IsNotExist(err) {
w.mu.Unlock()
if name == err.(*os.PathError).Path {
w.Error <- ErrWatchedFileDeleted
w.Remove(name)
}
w.mu.Lock()
} else {
w.Error <- err
}
w.mu.Lock()
} else {
w.Error <- err
}
}
}
Expand Down

0 comments on commit 5f1c168

Please sign in to comment.