Skip to content

Commit

Permalink
allow multiple space type fileters on decomposedfs
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 6a922e4 commit 50f9711
Show file tree
Hide file tree
Showing 2 changed files with 18 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
26 changes: 13 additions & 13 deletions pkg/storage/utils/decomposedfs/spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,16 @@ 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)
}
Expand All @@ -196,9 +196,14 @@ func (fs *Decomposedfs) ListStorageSpaces(ctx context.Context, filter []*provide
// /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 +237,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 50f9711

Please sign in to comment.