When a watched directory is unmounted/deleted? on Linux, fsnotify emits an event with the Op value 0 ("no events") up to ~1 minute later.
This happens when I plug in my camera via USB, let dolphin mount it, watching a mounted subdirectory with fsnotify, and then shutting off my camera.
I could only find this "no events" event mentioned under the "Windows notes" section of the documentation

This happens in fsnotify v1.7.0 and v1.8.0
$ uname -a
Linux kivah 5.15.0-119-generic #129-Ubuntu SMP Fri Aug 2 19:25:20 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Distro: Linux Mint 21.3 x86_64
Code to reproduce (click to expand)
package main
import (
"fmt"
"github.com/fsnotify/fsnotify"
)
func main() {
watcher, _ := fsnotify.NewWatcher()
defer watcher.Close()
watcher.Add("/mounted-directory/subdirectory")
go func() {
for {
select {
case event, ok := <-watcher.Events:
if !ok {
return
}
fmt.Println(event)
case _, ok := <-watcher.Errors:
if !ok {
return
}
}
}
}()
select {}
}
It would be nice to document that the received event.Op can be 0 in the Watcher struct documentation comments, especially since it can happen on both Windows & Linux.
Thanks!
When a watched directory is unmounted/deleted? on Linux, fsnotify emits an event with the Op value
0("no events") up to ~1 minute later.This happens when I plug in my camera via USB, let dolphin mount it, watching a mounted subdirectory with fsnotify, and then shutting off my camera.
I could only find this "no events" event mentioned under the "Windows notes" section of the documentation
This happens in fsnotify v1.7.0 and v1.8.0
Distro: Linux Mint 21.3 x86_64
Code to reproduce (click to expand)
It would be nice to document that the received
event.Opcan be0in the Watcher struct documentation comments, especially since it can happen on both Windows & Linux.Thanks!