Skip to content

Commit

Permalink
decomposedfs: make lookup.Path take into account share roots
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
  • Loading branch information
butonic committed Dec 20, 2021
1 parent 319edf7 commit b6ca718
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/storage/utils/decomposedfs/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (lu *Lookup) NodeFromSpaceID(ctx context.Context, id *provider.ResourceId)

// Path returns the path for node
func (lu *Lookup) Path(ctx context.Context, n *node.Node) (p string, err error) {
for n.ID != n.SpaceRoot {
for n.ID != n.SpaceRoot && !(n.ShareRoot != "" && n.ID != n.ShareRoot) {
p = filepath.Join(n.Name, p)
if n, err = n.Parent(); err != nil {
appctx.GetLogger(ctx).
Expand Down
10 changes: 3 additions & 7 deletions pkg/storage/utils/decomposedfs/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,13 +535,9 @@ func (n *Node) AsResourceInfo(ctx context.Context, rp *provider.ResourcePermissi
setPlainOpaque(ri, "root", n.SpaceRoot)
}

if returnBasename { // FIXME this is not the basename it is the path relative to the root
ri.Path = n.Name
} else {
ri.Path, err = n.lu.Path(ctx, n)
if err != nil {
return nil, err
}
ri.Path, err = n.lu.Path(ctx, n)
if err != nil {
return nil, err
}

ri.MimeType = mime.Detect(nodeType == provider.ResourceType_RESOURCE_TYPE_CONTAINER, ri.Path)
Expand Down

0 comments on commit b6ca718

Please sign in to comment.