Skip to content

Commit

Permalink
Add lock, use filepath.Join in test
Browse files Browse the repository at this point in the history
  • Loading branch information
arp242 committed Jul 22, 2022
1 parent 098b590 commit 338aaf0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions windows.go
Expand Up @@ -501,16 +501,17 @@ func (w *Watcher) readEvents() {
case syscall.FILE_ACTION_RENAMED_OLD_NAME:
watch.rename = name
case syscall.FILE_ACTION_RENAMED_NEW_NAME:

// update saved path of all sub-watches
// Update saved path of all sub-watches.
oldFullName := filepath.Join(watch.path, watch.rename)
w.mu.Lock()
for _, watchMap := range w.watches {
for _, otherWatch := range watchMap {
if strings.HasPrefix(otherWatch.path, oldFullName) {
otherWatch.path = filepath.Join(fullname, strings.TrimPrefix(otherWatch.path, oldFullName))
}
}
}
w.mu.Unlock()

if watch.names[watch.rename] != 0 {
watch.names[name] |= watch.names[watch.rename]
Expand Down

0 comments on commit 338aaf0

Please sign in to comment.