Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

fs.watch on Windows 7: Renaming a file does not emit event for original path #8372

Closed
jorangreef opened this issue Sep 15, 2014 · 6 comments
Closed
Labels

Comments

@jorangreef
Copy link

On Mac, using fs.watch on a directory, and then renaming a file in that directory, will emit two events, one for the file which was "deleted" and one for the file which was "created". Combining these two events later by comparing content can be used to detect renames.

But on Windows, no event is emitted for the original path. Is there no way to modify the usage of ReadDirectoryChangesW to get an event when the original path is removed or renamed to something else?

@bnoordhuis
Copy link
Member

It may be that libuv drops FILE_ACTION_RENAMED_OLD_NAME events. Do you get a 'rename' event with a null filename?

@jorangreef
Copy link
Author

Thanks Ben.

Yes, when renaming "a.txt" to "b.txt" I get the following events from fs.watch on Windows:

rename null
rename b.txt
change b.txt

Subsequently deleting "b.txt" just gives:

rename null

@bnoordhuis
Copy link
Member

Right, the null rename event is the FILE_ACTION_RENAMED_OLD_NAME event. I'm not sure why the filename is filtered out but it's not for feature parity with inotify. Should be easy to fix in libuv.

/cc @indutny or @saghul

@jorangreef
Copy link
Author

Thanks, that would be great.

@saghul
Copy link
Member

saghul commented Sep 15, 2014

@jorangreef Can you open an issue on libuv about this and link back here? Extra karma if you can work on a patch ;-)

@jorangreef
Copy link
Author

Thanks @saghul joyent/libuv#1479

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants