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

use space reference when listing containers #2432

Merged
merged 1 commit into from
Jan 11, 2022
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
5 changes: 5 additions & 0 deletions changelog/unreleased/use-space-reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: use space reference when listing containers

The propfind handler now uses the reference for a space to make lookups relative.

https://github.com/cs3org/reva/pull/2432
11 changes: 5 additions & 6 deletions internal/http/services/owncloud/ocdav/propfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ func (s *svc) getResourceInfos(ctx context.Context, w http.ResponseWriter, r *ht
var mostRecentChildInfo *provider.ResourceInfo
var aggregatedChildSize uint64
spaceInfos := make([]*provider.ResourceInfo, 0, len(spaces))
spaceMap := map[*provider.ResourceInfo]*provider.Reference{}
for _, space := range spaces {
if space.Opaque == nil || space.Opaque.Map == nil || space.Opaque.Map["path"] == nil || space.Opaque.Map["path"].Decoder != "plain" {
continue // not mounted
Expand All @@ -279,6 +280,7 @@ func (s *svc) getResourceInfos(ctx context.Context, w http.ResponseWriter, r *ht
info.Path = filepath.Join(spacePath, spaceRef.Path)
}

spaceMap[info] = spaceRef
spaceInfos = append(spaceInfos, info)

if rootInfo == nil && requestPath == info.Path || spacesPropfind && requestPath == path.Join("/", info.Path) {
Expand Down Expand Up @@ -354,14 +356,10 @@ func (s *svc) getResourceInfos(ctx context.Context, w http.ResponseWriter, r *ht
}

case spaceInfo.Type == provider.ResourceType_RESOURCE_TYPE_CONTAINER && depth == "1":

switch {
case strings.HasPrefix(requestPath, spaceInfo.Path):
req := &provider.ListContainerRequest{
Ref: &provider.Reference{
ResourceId: spaceInfo.Id,
Path: ".",
},
Ref: spaceMap[spaceInfo],
ArbitraryMetadataKeys: metadataKeys,
}
res, err := client.ListContainer(ctx, req)
Expand Down Expand Up @@ -418,7 +416,8 @@ func (s *svc) getResourceInfos(ctx context.Context, w http.ResponseWriter, r *ht
req := &provider.ListContainerRequest{
Ref: &provider.Reference{
ResourceId: spaceInfo.Id,
Path: utils.MakeRelativePath(strings.TrimPrefix(info.Path, spaceInfo.Path)),
// TODO here we cut of the path that we added after stating the space above
Path: utils.MakeRelativePath(strings.TrimPrefix(info.Path, spaceInfo.Path)),
},
ArbitraryMetadataKeys: metadataKeys,
}
Expand Down