Skip to content

Commit

Permalink
allow multiple space type fileters on decomposedfs (#2343)
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic committed Dec 8, 2021
1 parent 2dbf826 commit 3abd76e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Allow multiple space type fileters on decomposedfs

The decomposedfs driver now evaluates multiple space type filters when listing storage spaces.

https://github.com/cs3org/reva/pull/2343
29 changes: 16 additions & 13 deletions pkg/storage/utils/decomposedfs/spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,29 +176,37 @@ func (fs *Decomposedfs) ListStorageSpaces(ctx context.Context, filter []*provide
// we would not need /nodes/root if access always happened via spaceid+relative path

var (
spaceType = spaceTypeAny
spaceID = spaceIDAny
nodeID = spaceIDAny
err error
spaceID = spaceIDAny
nodeID = spaceIDAny
)

spaceTypes := []string{}

for i := range filter {
switch filter[i].Type {
case provider.ListStorageSpacesRequest_Filter_TYPE_SPACE_TYPE:
spaceType = filter[i].GetSpaceType()
spaceTypes = append(spaceTypes, filter[i].GetSpaceType())
case provider.ListStorageSpacesRequest_Filter_TYPE_ID:
spaceID, nodeID = utils.SplitStorageSpaceID(filter[i].GetId().OpaqueId)
}
}
if len(spaceTypes) == 0 {
spaceTypes = []string{"*"}
}

spaces := []*provider.StorageSpace{}
// build the glob path, eg.
// /path/to/root/spaces/{spaceType}/{spaceId}
// /path/to/root/spaces/personal/nodeid
// /path/to/root/spaces/shared/nodeid
matches, err := filepath.Glob(filepath.Join(fs.o.Root, "spaces", spaceType, nodeID))
if err != nil {
return nil, err

matches := []string{}
for _, spaceType := range spaceTypes {
m, err := filepath.Glob(filepath.Join(fs.o.Root, "spaces", spaceType, nodeID))
if err != nil {
return nil, err
}
matches = append(matches, m...)
}

u, ok := ctxpkg.ContextGetUser(ctx)
Expand Down Expand Up @@ -232,11 +240,6 @@ func (fs *Decomposedfs) ListStorageSpaces(ctx context.Context, filter []*provide

spaceType := filepath.Base(filepath.Dir(matches[i]))

// if spaceType == "share" {
// do not list shares at all? the sharesstorageprovider is responsible for it
// continue
// }

owner, err := n.Owner()
if err != nil {
appctx.GetLogger(ctx).Error().Err(err).Interface("node", n).Msg("could not read owner, skipping")
Expand Down

0 comments on commit 3abd76e

Please sign in to comment.