Allow nesting of trees
Makes Tree implement ICollection and modify getNodeForPath to pass the request to nested trees.
My main use case for this in Nextcloud is that for part of the tree we can optimize getNodeForPath by directly getting the target node instead of going trough all parent nodes, but there is currently no clean way to apply this optimization to only a part of the dav tree.
With nested trees we could put this optimization in a separate Tree subclass and nest it into the "main" tree.
I've been considering doing this exact thing for a while, because it kind of allows for a sort of 'mounting' type of system.
However, the methods having multiple purposes (delete() vs delete($path)) makes me feel a bit uncomfortable.
So one thing I'm wondering is, could it make sense to instead just add a new interface that only defines the getNodeForPath() function. (or maybe getChildByPath(), idk), or does that not satisfy your use-case?
I'm also not a fan of the method name conflicts.
A separate interface for just the getNodeForPath would probably cover the specific use case I started the work for but having full nesting of trees would most likely be useful in future cases (I'm fairly sure it would allow us to do some good code reuse)
Well, adding a separate interface for this one function might simply be a step in the right direction. I don't think we'd paint ourselves into a corner if we do have real use-cases for having the other methods.
True.
I would go for getNodeForPath instead of getChildByPath or something similar because then Tree can simply implement the new interface.
I'll look into implementing this tomorrow
Codecov Report
Merging #1059 into master will decrease coverage by
0.15%. The diff coverage is58.06%.
@@ Coverage Diff @@
## master #1059 +/- ##
============================================
- Coverage 97.92% 97.76% -0.16%
- Complexity 2867 2880 +13
============================================
Files 174 174
Lines 7898 7919 +21
============================================
+ Hits 7734 7742 +8
- Misses 164 177 +13
| Impacted Files | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| lib/DAV/Tree.php | 89.68% <58.06%> (-10.32%) |
54 <15> (+13) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update c077d66...02f6996. Read the comment docs.
@icewind1991 let's revive this once work continues on #1060
@icewind1991 rebase and move on? :wink:
feel free to reopen if this is still of interest