diff --git a/changelog/unreleased/wrap-recycle-paths.md b/changelog/unreleased/wrap-recycle-paths.md new file mode 100644 index 00000000000..6f818149f8f --- /dev/null +++ b/changelog/unreleased/wrap-recycle-paths.md @@ -0,0 +1,3 @@ +Bugfix: Return wrapped paths for recycled items in storage provider + +https://github.com/cs3org/reva/pull/2368 \ No newline at end of file diff --git a/internal/grpc/services/storageprovider/storageprovider.go b/internal/grpc/services/storageprovider/storageprovider.go index aac7f68453c..6509e30bf90 100644 --- a/internal/grpc/services/storageprovider/storageprovider.go +++ b/internal/grpc/services/storageprovider/storageprovider.go @@ -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, @@ -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 { diff --git a/internal/http/services/owncloud/ocdav/trashbin.go b/internal/http/services/owncloud/ocdav/trashbin.go index 7d27aa09641..9529d665805 100644 --- a/internal/http/services/owncloud/ocdav/trashbin.go +++ b/internal/http/services/owncloud/ocdav/trashbin.go @@ -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, @@ -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)