Skip to content

Commit

Permalink
Return wrapped paths for recycled items in storage provider
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Dec 13, 2021
1 parent 778de37 commit 76cc9d9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
3 changes: 3 additions & 0 deletions changelog/unreleased/wrap-recycle-paths.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bugfix: Return wrapped paths for recycled items in storage provider

https://github.com/cs3org/reva/pull/2368
21 changes: 21 additions & 0 deletions internal/grpc/services/storageprovider/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,15 @@ func (s *service) ListRecycle(ctx context.Context, req *provider.ListRecycleRequ
}, nil
}

prefixMountpoint := utils.IsAbsoluteReference(req.Ref)
for _, md := range items {
if err := s.wrapReference(ctx, md.Ref, prefixMountpoint); err != nil {
return &provider.ListRecycleResponse{
Status: status.NewInternal(ctx, err, "error wrapping path"),
}, nil
}
}

res := &provider.ListRecycleResponse{
Status: status.NewOK(ctx),
RecycleItems: items,
Expand Down Expand Up @@ -1395,6 +1404,18 @@ func (s *service) wrap(ctx context.Context, ri *provider.ResourceInfo, prefixMou
return nil
}

func (s *service) wrapReference(ctx context.Context, ref *provider.Reference, prefixMountpoint bool) error {
if ref.ResourceId != nil && ref.ResourceId.StorageId == "" {
// For wrapper drivers, the storage ID might already be set. In that case, skip setting it
ref.ResourceId.StorageId = s.mountID
}
if prefixMountpoint {
// TODO move mount path prefixing to the gateway
ref.Path = path.Join(s.mountPath, ref.Path)
}
return nil
}

type descendingMtime []*provider.FileVersion

func (v descendingMtime) Len() int {
Expand Down
6 changes: 2 additions & 4 deletions internal/http/services/owncloud/ocdav/trashbin.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,7 @@ func (h *TrashbinHandler) restore(w http.ResponseWriter, r *http.Request, s *svc
return
}

dstRef := &provider.Reference{
Path: path.Join(basePath, dst),
}
dstRef := &provider.Reference{Path: dst}

dstStatReq := &provider.StatRequest{
Ref: dstRef,
Expand Down Expand Up @@ -544,7 +542,7 @@ func (h *TrashbinHandler) restore(w http.ResponseWriter, r *http.Request, s *svc
Path: basePath,
},
Key: path.Join(key, itemPath),
RestoreRef: &provider.Reference{Path: dst},
RestoreRef: dstRef,
}

res, err := client.RestoreRecycleItem(ctx, req)
Expand Down

0 comments on commit 76cc9d9

Please sign in to comment.