Open lptr opened 4 years ago
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).
I was suspecting that using File.renameTo()
might do something weird, but running REN source.txt target.txt
in PowerShell produces the same events.
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
totarget.txt
in a watched directory: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
) fortarget.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.