From 5c6d9497ee647310e6e7a49e56f2abdecc6ded6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Tue, 11 Jan 2022 16:03:47 +0100 Subject: [PATCH] use space reference when listing containers (#2432) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- changelog/unreleased/use-space-reference.md | 5 +++++ internal/http/services/owncloud/ocdav/propfind.go | 11 +++++------ 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 changelog/unreleased/use-space-reference.md diff --git a/changelog/unreleased/use-space-reference.md b/changelog/unreleased/use-space-reference.md new file mode 100644 index 00000000000..ca93f75a789 --- /dev/null +++ b/changelog/unreleased/use-space-reference.md @@ -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 diff --git a/internal/http/services/owncloud/ocdav/propfind.go b/internal/http/services/owncloud/ocdav/propfind.go index cf7ebe3f930..9732e06ca73 100644 --- a/internal/http/services/owncloud/ocdav/propfind.go +++ b/internal/http/services/owncloud/ocdav/propfind.go @@ -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 @@ -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) { @@ -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) @@ -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, }