Search code examples
watchman

is watchman notifies for deleted files?


I tried to find in the documentation and I did not find indication.

I read the win32 watch code (because I am familiar with the API and it seems it does not).

Tracking for file deletion is extremely convoluted on windows, because the API provides the file names "randomly" mangled and if the file is not there anymore to resolve the real name "long path" it is hard to say what was the original.

I have implemented such thing for my previous company, with preserving the current state of files and reconciling the list of files for every directory that changes were happening inside. It worked well.

My question is: did I miss it and watchman notifies for deleted files? And if it does not - is there plans for these notifications to be added in the near future.


Solution

  • The short answer: yes.

    The longer answer: the more convoluted portions are not entirely windows specific.

    The bit that handles the mangled names can be found here: https://github.com/facebook/watchman/blob/master/root.c#L748

    The bit that handles deletes is in two parts; the first handles things when we're checking exactly the file that we were notified about: https://github.com/facebook/watchman/blob/master/root.c#L853

    The second is a kind of "garbage collection" approach where we're looking at the containing directory and discover that the file has gone away: https://github.com/facebook/watchman/blob/master/root.c#L1353