-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debounced Create/Rename/Remove is out of order for tempfiles #129
Comments
This looks like an issue with DebouncedEvents. It works as expected if I set the debounce timer to 0. The following testcase demonstrates this:
|
This only happens on Windows, or is that just where you tested? |
I initially tested it only on Windows, but I have now also confirmed that the issue happens on a Linux machine. |
I'm not entirely certain this is a bug. Order of events is not something that's very guaranteed, even at the platform level. Is this just something you noticed, or does it cause an issue with your usecase? |
It's causing an issue with my usecase, however I've worked around it by creating my own debounce queue and disabling debounce in notify. The behavior is somewhat surprising and took me a while to track down, which is why I opened the issue. My application is monitoring a directory for unit files, much like systemd. When a unit file is added, it is activated. When a unit file is removed, it is deactivated. If you edit a unit file in vim and save it, because of the out-of-order messages, the "remove" message will come last which will cause the unit file to be removed from the unit table. |
Thanks for reporting. This was a tricky bug. I changed the behavior of the debounce module to ignore all events for files that have been moved and deleted while a new file at the original location has been created. From the user's point of view this is as if the original file was modified. Just instead of a |
That shouldn't be a problem. Thanks for fixing it so quickly! |
When updating files on Windows, the Create event comes before the Rename and Remove events. This is particularly noticeable when using vi, which creates swap files first and does a rename().
Using the example program, changing the path to my own path D:/Code/rust/test-notify and running 4.0.1:
For this test, I create the empty directory "notify", then run the program. As the program is run, I use vim to edit order-test.txt, save it, modify it, and save it again:
The first Create() is when I open vim, the second Create() is when I save the file. The final NoticeWrite()/Write()/Create()/Rename()/Remove() comes when I save the modified file.
The Rename() should come before the Create().
The text was updated successfully, but these errors were encountered: