Skip to content

inotify: fix recursive directory rename handling - #5

Open
allenanswerzq wants to merge 1 commit into
syncthing:mainfrom
allenanswerzq:fix/inotify-directory-rename
Open

allenanswerzq wants to merge 1 commit into
syncthing:mainfrom
allenanswerzq:fix/inotify-directory-rename

Conversation

@allenanswerzq

Copy link
Copy Markdown

Fixes the Linux recursive-watcher failure described in rjeczalik#227 for the Syncthing fork.

Recursive watches maintain an internal tree of per-directory inotify watches. Directory removal, recreation, and rename events could be processed out of order, leaving watch descriptors associated with stale paths. Subsequent file events could therefore report the previous path or be dropped entirely.

This change:

  • preserves inotify event ordering;
  • serializes recursive-tree event dispatch;
  • removes stale tree nodes on directory rename;
  • maintains the tree when callers request native inotify events; and
  • adds regression tests for a directory renamed away and back.

Verification:

  • go test ./...
  • go test -race ./...
  • rename regression tests passed 30 repeated runs
  • TestRecreated passed 30 repeated runs

Without the fix, the new regression tests consistently report events using the stale temporary/file path instead of original/file.

@allenanswerzq

Copy link
Copy Markdown
Author

this pr should also fix this syncthing/syncthing#7950

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant