dav icon indicating copy to clipboard operation
dav copied to clipboard

Allow nesting of trees

Open icewind1991 opened this issue 7 years ago • 7 comments

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.

icewind1991 avatar May 24 '18 14:05 icewind1991

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?

evert avatar May 24 '18 17:05 evert

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)

icewind1991 avatar May 24 '18 23:05 icewind1991

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.

evert avatar May 24 '18 23:05 evert

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

icewind1991 avatar May 24 '18 23:05 icewind1991

Codecov Report

Merging #1059 into master will decrease coverage by 0.15%. The diff coverage is 58.06%.

Impacted file tree graph

@@             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 data Powered by Codecov. Last update c077d66...02f6996. Read the comment docs.

codecov-io avatar May 25 '18 10:05 codecov-io

@icewind1991 let's revive this once work continues on #1060

DeepDiver1975 avatar Nov 09 '23 14:11 DeepDiver1975

@icewind1991 rebase and move on? :wink:

DeepDiver1975 avatar Nov 13 '23 22:11 DeepDiver1975

feel free to reopen if this is still of interest

DeepDiver1975 avatar Sep 05 '24 09:09 DeepDiver1975