synology_apm_repo.sdk.units.resolve module¶
Resolving a NodeRef against a provider’s tree without visiting every
node in it — shared by Repository.resolve (which only needs the final
Node) and the TUI’s goto-ref feature (which also needs the full
ancestor chain and each ancestor’s own children, to repopulate a Tree
widget).
For a provider whose extra_segments grow by exactly one new segment per
tree level (true for every provider except Drive/Team Drive, which key
every node by a single, depth-independent id instead), a target’s extra_segments
is a real, checkable prefix relationship: a child is only worth
descending into when its own ref is a prefix of the target’s.
find_node/find_path_with_children use exactly that to visit only the
nodes on the real path to the target, never a non-matching sibling’s
subtree — unlike a plain depth-first search, whose cost is the size of
the whole tree regardless of where the target sits. A provider that
can’t support this prefix relationship instead implements
SupportsDirectRefLookup, checked here via isinstance before falling
back to the descent.
- async synology_apm_repo.sdk.units.resolve.find_node(provider, target)¶
The single
Nodewhose ownrefequalstarget, orNone. Visits only the nodes on the real path totarget— never a non-matching sibling’s subtree.
- async synology_apm_repo.sdk.units.resolve.find_path_with_children(provider, target)¶
(chain, children_by_step)fortarget—chainis[root, ..., target];children_by_step[i]is the complete (fully paginated) list ofchain[i]’s own children, for every ancestor up to but not includingtargetitself.Noneiftargetisn’t in this tree at all.