Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow multiple space type filters on decomposedfs #2343

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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