Skip to content

Commit

Permalink
use space reference when listing containers (cs3org#2432)
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 Feb 14, 2022
1 parent 2469457 commit 5c6d949
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
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

0 comments on commit 5c6d949

Please sign in to comment.