3 ms·
For what it's worth, I've written plenty of code using file watching. I did a build system that needed to watch the file system to pick up file changes. You're
by munificent 3y ago
For what it's worth, I've written plenty of code using file watching. I did a build system that needed to watch the file system to pick up file changes.
You're absolutely right that file watching gets really hairy really fast. Sometimes you won't get events for files. Renaming directories can make things get all kinds of weird. Sometimes you'll get a flurry of updates for the same file and you need to debounce. It's a mess.
But the actual atomic primitive events themselves I've found to be fairly simple. It's basically just write, delete, and rename. I think modeling that as a sum type of a sealed class hierarchy works fine.
Most of the problems are a level above where the set of events is hard to parse meaningfully.