I added a test based on the example posted in #200.
The main change is to also pass Remove events to t.rec, and then unwatch and delete nodes under that path. Thus when it gets created again, new watches will be set up (instead of keeping the old, now invalid watches).
I also fixed some stuff I encountered while debugging and fixing:
go.mod always changes when running anything like tests. I chose 1.11 because that's when modules started - earlier versions anyway don't care about go.mod.
Don't re-add already existing created directories - that lead to empty leave nodes (however shouldn't happen any more now that deleted dirs are removed - still better be safe).
indexbase is needlessly complicated. All functions where it is called return an error if the root and name are equal. I thus chaned it to return -1 if root and name are equal. And renamed it to indexrel, as it's the first index of the path relative to root, not the last element in name.
I added a test based on the example posted in #200.
The main change is to also pass
Remove
events tot.rec
, and then unwatch and delete nodes under that path. Thus when it gets created again, new watches will be set up (instead of keeping the old, now invalid watches).I also fixed some stuff I encountered while debugging and fixing:
indexbase
is needlessly complicated. All functions where it is called return an error if the root and name are equal. I thus chaned it to return-1
ifroot
andname
are equal. And renamed it toindexrel
, as it's the first index of the path relative to root, not the last element in name.