Open roberth opened 5 years ago
If you had written how you noticed this we might have figured this and that a bit sooner :)
Catching a few files too much didn't seem that bad, but I agree in general more info is good.
Okay, so what needs to be done here:
This needs to be split into two constructors, one for files and one for dirs (and logged-evaluation.nix
changed to print different things):
Then we need some more logic here:
cc @curiousleo
This needs to be split into two constructors, one for files and one for dirs (and
logged-evaluation.nix
changed to print different things)
I think there may be a "smaller diff" solution to the problem at hand: just don't watch directories recursively. Note that when watching a directory, notify
will still tell us when any of its children are updated:
If
recursive_mode
isRecursiveMode::Recursive
events will be delivered for all files in that tree. Otherwise only the directory and its immediate children will be watched.
https://docs.rs/notify/5.0.0-pre.1/notify/trait.Watcher.html#tymethod.watch
"only the directory and its immediate children" seems to be exactly what is needed here.
My Nix-foo isn't good enough to be 100% sure that this is the correct behaviour, but according to what @roberth said about readDir
, it seems fine ...? Draft PR here: https://github.com/target/lorri/pull/232.
Lorri seems to watch directories recursively when it detects
builtins.readDir
. This seems unnecessary becausereadDir
only returns the direct children. Any use of those children should be detectable with existing means.