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

Populate share jail #2884

Merged
merged 3 commits into from
May 19, 2022
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions changelog/unreleased/populate-share-jail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: show mounted shares in virtual share jail root

The virtual share jail now shows the mounted shares to allow the desktop client to sync that collection.

https://github.com/cs3org/reva/pull/2884
https://github.com/owncloud/ocis/issues/3719
1 change: 1 addition & 0 deletions internal/grpc/services/gateway/usershareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ func (s *svc) ListReceivedShares(ctx context.Context, req *collaboration.ListRec
// The `ListStorageSpaces` method in sharesstorageprovider/sharesstorageprovider.go needs the etags.
shareMetaData := make(map[string]share.Metadata, len(res.Shares))
for _, rs := range res.Shares {
// FIXME: usershareprovider should not stat resources
sRes, err := s.Stat(ctx, &provider.StatRequest{Ref: &provider.Reference{ResourceId: rs.Share.ResourceId}})
if err != nil {
logger.Error().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,10 @@ func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStora
if spaceID == nil || utils.ResourceIDEqual(virtualRootID, spaceID) {
earliestShare, atLeastOneAccepted := findEarliestShare(receivedShares, shareMd)
var opaque *typesv1beta1.Opaque
var mtime *typesv1beta1.Timestamp
if earliestShare != nil {
if md, ok := shareMd[earliestShare.Id.OpaqueId]; ok {
mtime = md.Mtime
opaque = utils.AppendPlainToOpaque(opaque, "etag", md.ETag)
}
}
Expand All @@ -398,8 +400,9 @@ func (s *service) ListStorageSpaces(ctx context.Context, req *provider.ListStora
SpaceType: "virtual",
//Owner: &userv1beta1.User{Id: receivedShare.Share.Owner}, // FIXME actually, the mount point belongs to the recipient
// the sharesstorageprovider keeps track of mount points
Root: virtualRootID,
Name: "Shares Jail",
Root: virtualRootID,
Name: "Shares Jail",
Mtime: mtime,
}
res.StorageSpaces = append(res.StorageSpaces, space)
}
Expand Down Expand Up @@ -761,9 +764,55 @@ func (s *service) ListContainer(ctx context.Context, req *provider.ListContainer

if isVirtualRoot(req.Ref.ResourceId) {
// The root is empty, it is filled by mountpoints
// but when accessing the root via /dav/spaces we need to list the content

receivedShares, _, err := s.fetchShares(ctx)
if err != nil {
return nil, errors.Wrap(err, "sharesstorageprovider: error calling ListReceivedSharesRequest")
}

infos := []*provider.ResourceInfo{}
for _, share := range receivedShares {
if share.GetState() != collaboration.ShareState_SHARE_STATE_ACCEPTED {
continue
}

statRes, err := s.gateway.Stat(ctx, &provider.StatRequest{
Opaque: req.Opaque,
Ref: &provider.Reference{
ResourceId: share.Share.ResourceId,
Path: ".",
},
ArbitraryMetadataKeys: req.ArbitraryMetadataKeys,
})
switch {
case err != nil:
appctx.GetLogger(ctx).Error().
Err(err).
Interface("share", share).
Msg("sharesstorageprovider: could not make stat request when listing virtual root, skipping")
continue
case statRes.Status.Code != rpc.Code_CODE_OK:
appctx.GetLogger(ctx).Debug().
Interface("share", share).
Interface("status", statRes.Status).
Msg("sharesstorageprovider: could not stat share when listing virtual root, skipping")
continue
}

// override info
info := statRes.Info
info.Id = &provider.ResourceId{
StorageId: utils.ShareStorageProviderID,
OpaqueId: share.Share.Id.OpaqueId,
}
info.Path = filepath.Base(share.MountPoint.Path)

infos = append(infos, info)
}
return &provider.ListContainerResponse{
Status: status.NewOK(ctx),
Infos: []*provider.ResourceInfo{},
Infos: infos,
}, nil
}
receivedShare, rpcStatus, err := s.resolveReference(ctx, req.Ref)
Expand Down