recwatch: Remove watcher on file move

Fix #120

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
This commit is contained in:
Julien Pivotto
2017-02-11 11:53:16 +01:00
parent 6ba7422c3b
commit de9a32a273
3 changed files with 56 additions and 0 deletions

View File

@@ -247,6 +247,13 @@ func (obj *RecWatcher) Watch() error {
index--
}
// when the file is moved, remove the watcher and add a new one,
// so we stop tracking the old inode.
if deltaDepth >= 0 && (event.Op&fsnotify.Rename == fsnotify.Rename) {
obj.watcher.Remove(current)
obj.watcher.Add(current)
}
// we must be a parent watcher, so descend in
if deltaDepth < 0 {
// XXX: we can block here due to: https://github.com/fsnotify/fsnotify/issues/123