Skip to content
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

Windows file watcher reports renames incorrectly #59

Open
lptr opened this issue Dec 13, 2019 · 2 comments
Open

Windows file watcher reports renames incorrectly #59

lptr opened this issue Dec 13, 2019 · 2 comments

Comments

@lptr
Copy link
Member

lptr commented Dec 13, 2019

The Windows native watcher currently sends one event for the removal of the source path, and no event for the target path.

For some reason we get events like this when renaming source.txt to target.txt in a watched directory:

~~~~ Configuring...
~~~~ Watching C:\Users\vmadmin\AppData\Local\Temp\junit3569962616360979317\junit2117301140375774919\
~~~~ Starting thread
~~~~ Changed: 4 C:\Users\vmadmin\AppData\Local\Temp\junit3569962616360979317\junit2117301140375774919\source.txt
~~~~ Changed: 3 C:\Users\vmadmin\AppData\Local\Temp\junit3569962616360979317\junit2117301140375774919
~~~~ Ignoring C:\Users\vmadmin\AppData\Local\Temp\junit3569962616360979317\junit2117301140375774919 (root is not watched)
~~~~ Stopping thread

The event we get for source.txt (4 = FILE_ACTION_RENAMED_OLD_NAME) is correct, but we should be getting a number 5 event (FILE_ACTION_RENAMED_OLD_NAME) for target.txt according to the (docs)[https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-file_notify_information]. Instead we get a 3 (FILE_ACTION_MODIFIED ) for the parent directory.

@lptr
Copy link
Member Author

lptr commented Dec 13, 2019

Note that this is only a problem when renaming the file, i.e. when it stays in the same directory. Moving the file generates the correct FILE_ACTION_REMOVED + FILE_ACTION_ADDED events (plus another FILE_ACTION_MODIFIED for the directory of the target for some reason).

@lptr
Copy link
Member Author

lptr commented Dec 13, 2019

I was suspecting that using File.renameTo() might do something weird, but running REN source.txt target.txt in PowerShell produces the same events.

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

No branches or pull requests

1 participant