Skip to content

Commit

Permalink
Sketched fix
Browse files Browse the repository at this point in the history
  • Loading branch information
arnegroskurth authored and arp242 committed Jul 22, 2022
1 parent e56409e commit ec2ac5c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"path/filepath"
"reflect"
"runtime"
"strings"
"sync"
"syscall"
"unsafe"
Expand Down Expand Up @@ -500,6 +501,15 @@ 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
oldFullName := filepath.Join(watch.path, watch.rename)
for _, otherWatch := range w.watches {
if strings.HasPrefix(otherWatch.path, oldFullName) {
otherWatch.path = filepath.Join(watch.path, strings.TrimPrefix(otherWatch.path, oldFullName))
}
}

if watch.names[watch.rename] != 0 {
watch.names[name] |= watch.names[watch.rename]
delete(watch.names, watch.rename)
Expand Down

0 comments on commit ec2ac5c

Please sign in to comment.