From d0d7449196b11be427cd3b861d284212c59fd3fb Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 28 May 2020 08:33:51 +0200 Subject: [PATCH] Separate PROPFIND logic for Depth 1 and infinity (#779) Switching to path concatenation broke some cross-storage cases. Since clients currently only use Depth 1, here we make sure that at least this works. For the infinity case, it is limited to single storage recursion for now. --- .../http/services/owncloud/ocdav/propfind.go | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/internal/http/services/owncloud/ocdav/propfind.go b/internal/http/services/owncloud/ocdav/propfind.go index f172cb117f..5b81a22b49 100644 --- a/internal/http/services/owncloud/ocdav/propfind.go +++ b/internal/http/services/owncloud/ocdav/propfind.go @@ -97,7 +97,25 @@ func (s *svc) handlePropfind(w http.ResponseWriter, r *http.Request, ns string) info := res.Info infos := []*provider.ResourceInfo{info} - if info.Type == provider.ResourceType_RESOURCE_TYPE_CONTAINER && depth != "0" { + if info.Type == provider.ResourceType_RESOURCE_TYPE_CONTAINER && depth == "1" { + req := &provider.ListContainerRequest{ + Ref: ref, + } + res, err := client.ListContainer(ctx, req) + if err != nil { + log.Error().Err(err).Msg("error sending list container grpc request") + w.WriteHeader(http.StatusInternalServerError) + return + } + + if res.Status.Code != rpc.Code_CODE_OK { + log.Err(err).Msg("error calling grpc list container") + w.WriteHeader(http.StatusInternalServerError) + return + } + infos = append(infos, res.Infos...) + } else if depth == "infinity" { + // FIXME: doesn't work cross-storage as the results will have the wrong paths! // use a stack to explore sub-containers breadth-first stack := []string{info.Path} for len(stack) > 0 {