3 ms·
> All I want from filesystem watcher is to track files by pattern and just re-run the command, however complex that may be to implement via OS interfaces. I as
by Adverblessly 6y ago
> All I want from filesystem watcher is to track files by pattern and just re-run the command, however complex that may be to implement via OS interfaces.
I assume I'm misunderstanding something, so this is probably a naive question and maybe you can explain further, but if that is all you need why not just write it yourself? It sounds like an <1 hour project to write something cross-platform in Qt that monitors the filesystem recursively with QFileSystemWatcher https://doc.qt.io/qt-5/qfilesystemwatcher.html https://doc.qt.io/qt-5/qfilesystemwatcher.html checks for the configured regexen and runs the configured command.
- hobo_mark 6y agoWhat's wrong with watchman? Seems to be made for that very use case. https://facebook.github.io/watchman/ https://facebook.github.io/watchman/
- klodolph 6y agoI have implemented stuff like this. It is not even remotely a <1 hour project. Not if you want it to work reasonably well and not be broken all the time. It’s a full workday for someone who already understands the problem. There are a number of cases you often want to handle: - Multiple files may change in quick succession, for example, if you hit “save all” in an editor. You might want to delay triggers to see if more events arrive. - You will sometimes see incomplete / corrupted versions of files, because you ran a command while another program was writing the file. The other program probably should atomically rewrite the file, but you’re stuck fixing the problem. The user doesn’t want to see errors from this and you generally want to rerun the command. - You need to execute commands in the correct order. - A command may change state from being queued&ready to having outdated inputs. If it’s just one command, sure, you could probably do it in an hour. But if there’s more than one command (usually the case!) then it gets far more complicated. Just looking at the last time I implemented something like this--it was watchman + about 500 lines of code figuring out which actions to run and when. And that’s not even with any parallel execution.