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

ocdav: use reference instead of path in PROPFIND #778

Closed
wants to merge 1 commit into from
Closed
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
19 changes: 11 additions & 8 deletions internal/http/services/owncloud/ocdav/propfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,31 @@ func (s *svc) handlePropfind(w http.ResponseWriter, r *http.Request, ns string)
infos := []*provider.ResourceInfo{info}
if info.Type == provider.ResourceType_RESOURCE_TYPE_CONTAINER && depth != "0" {
// use a stack to explore sub-containers breadth-first
stack := []string{info.Path}
stack := []*provider.ResourceInfo{info}
for len(stack) > 0 {
// retrieve path on top of stack
path := stack[len(stack)-1]
ref = &provider.Reference{
Spec: &provider.Reference_Path{Path: path},
}
nextInfo := stack[len(stack)-1]
req := &provider.ListContainerRequest{
Ref: ref,
}
res, err := client.ListContainer(ctx, req)
if err != nil {
log.Error().Err(err).Str("path", path).Msg("error sending list container grpc request")
log.Error().Err(err).Str("path", nextInfo.Path).Msg("error sending list container grpc request")
w.WriteHeader(http.StatusInternalServerError)
return
}
if res.Status.Code != rpc.Code_CODE_OK {
log.Err(err).Str("path", path).Msg("error calling grpc list container")
log.Err(err).Str("path", nextInfo.Path).Msg("error calling grpc list container")
w.WriteHeader(http.StatusInternalServerError)
return
}

ref = &provider.Reference{
Spec: &provider.Reference_Id{
Id: nextInfo.Id,
},
}

infos = append(infos, res.Infos...)

if depth != "infinity" {
Expand All @@ -136,7 +139,7 @@ func (s *svc) handlePropfind(w http.ResponseWriter, r *http.Request, ns string)
for i := len(res.Infos) - 1; i >= 0; i-- {
//for i := range res.Infos {
if res.Infos[i].Type == provider.ResourceType_RESOURCE_TYPE_CONTAINER {
stack = append(stack, res.Infos[i].Path)
stack = append(stack, res.Infos[i])
}
}
}
Expand Down