Drop watches of directories that leave the tree
A directory moved out of a watched tree kept its kernel watches, so later changes inside it were reported under the old path. Its watches and those of its subdirectories are now removed on `MOVED_FROM`. Watches the kernel reports as `IGNORED` are forgotten as well, so a reused descriptor number cannot map to a stale path.
This commit is contained in:
@@ -36,6 +36,14 @@ struct InotifyWatchManager {
|
||||
return self.watchPaths[watchDescriptor]
|
||||
}
|
||||
|
||||
/// The descriptors of the watch on `path` itself and of every watch below it.
|
||||
func descriptors(under path: String) -> [CInt] {
|
||||
let prefix = path.hasSuffix("/") ? path : path + "/"
|
||||
return self.watchPaths
|
||||
.filter { $0.value == path || $0.value.hasPrefix(prefix) }
|
||||
.map(\.key)
|
||||
}
|
||||
|
||||
func mask(forId watchDescriptor: CInt) -> InotifyEventMask? {
|
||||
return self.watchMasks[watchDescriptor]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user