]> go.fuhry.dev Git - fsnotify.git/commit
inotify: remove watch when renaming a watched path (#518)
authorMartin Tournoij <martin@arp242.net>
Fri, 14 Oct 2022 16:34:36 +0000 (18:34 +0200)
committerGitHub <noreply@github.com>
Fri, 14 Oct 2022 16:34:36 +0000 (18:34 +0200)
commitd314f6d898c86252e6f28cf6e25826a58d0b894c
treea1d9ea277b475bce8febc29feb1e0006c194491a
parentaaabe109285e92d579a78b9192ff387f010eaf6b
inotify: remove watch when renaming a watched path (#518)

Renaming a watched path is problematic; on inotify we just get a
IN_MOVED_SELF event with the old filename and that's it; no more events
for you! So if you do:

watch one
mv    one two
cat   asd >two

You still continue to get events for the file "one", even though it's
now named "two" (the file descriptor doesn't care about the rename).
There is no way we can know the new event as far as I can tell,
inotifywait(1) also behaves like this. So instead of continuing in a
semi-broken state just remove the watcher, like we do for deletes.

On kqueue and FEN the situation is similar, and we actually already
removed watchers on renames.

On Windows this all works nicely; the watch is preserved and the
filename is updated. I decided to keep this as-is for now, even though
it's inconsistent. We actually fixed the Windows behaviour for the 1.6.0
release in #370 , so people do seem to care about it and use it, and
experience with the symlink change in 1.5.0 shows it's better to keep
inconsistent behaviour rather than change it. Fixing this up is
something for a v2.

Fixes #172
Fixes #503
CHANGELOG.md
backend_fen.go
backend_inotify.go
backend_kqueue.go
backend_other.go
backend_windows.go
fsnotify_test.go
mkdoc.zsh