joyent/node — pull request #3410 by btrask (2012-06-12 02:05:35+00:00)
Title: Patch to improve the functionality of fs.watch() by enhancing both Node and libuv

I wanted to submit this directly to libuv, but since it requires changes in Node too, I thought I should put it here first.

Changes in libuv:
* `uv_fs_event` enum is defined with bit-shifts, which make the intent obvious
* Adds new `uv_fs_event` type, UV_REVOKE, for files that are deleted or unmounted
* Filenames are loaded and passed to the callback with kqueue just like they are on other platforms (Windows, etc.)

Changes in Node:
* Support for UV_REVOKE (passed to fs.watch() callbacks as "revoke")
* No change related to filenames, since it is already supported for some platforms

Issues:
* Probably breaks the libuv build on non-OS X platforms that use Kqueue (FreeBSD?), because it uses F_FULLFSYNC in order to get the latest filename after a rename operation (see the comment in the path about this)
* Furthermore, may not always return the latest filename on platforms without F_FULLFSYNC support
* No UV_REVOKE support is added to any of the other libuv platforms (I don't have access to them)

I know this patch causes as many problems as it solves, but I hope it can serve as a starting point to improve file event support.

Thanks,
Ben