Skip to content

Commit

Permalink
Implement a publicshare manager using the metadata storage backend (#…
Browse files Browse the repository at this point in the history
…2644)

* Move Indexer and Storage interfaces to their libraries for reusability

* Fix naming of nested field indexes

* Add initial version of the cs3-based publicshare manager

* Cleanup unused parameter

* Return empty result instead of error when listed directory doesn't exist

* Implement ListPublicShares

* Add support for adding signature to the returned public shares

* Implement RevokePublicShare

* Extract authenticate into the main package for reusability

* Implement GetPublicShareByToken

* More API cleanup

* Add config and make NewDefault work

* Implement UpdatePublicShare

* Fix rebase artifact

* Improve tests

* Make sure to always initialize the manager

* Fix tests

* Return NotFoundErr if there is no match

* Linter fixes

* Add changelog

* Make sure to address the proper index

* Make sure to initialize the manager atomically

* Fix setting the display name from the metadata

* Improve style according to review
  • Loading branch information
aduffeck authored Mar 21, 2022
1 parent 5a93e51 commit 58de124
Show file tree
Hide file tree
Showing 20 changed files with 1,037 additions and 77 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/cs3-publicshare-manager.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: add new public share manager

We added a new public share manager which uses the new metadata storage backend for
persisting the public share information.

https://github.com/cs3org/reva/pull/2644
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"regexp"

link "github.com/cs3org/go-cs3apis/cs3/sharing/link/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/v2/pkg/appctx"
ctxpkg "github.com/cs3org/reva/v2/pkg/ctx"
"github.com/cs3org/reva/v2/pkg/errtypes"
Expand Down Expand Up @@ -226,7 +225,7 @@ func (s *service) ListPublicShares(ctx context.Context, req *link.ListPublicShar
log.Info().Str("publicshareprovider", "list").Msg("list public share")
user, _ := ctxpkg.ContextGetUser(ctx)

shares, err := s.sm.ListPublicShares(ctx, user, req.Filters, &provider.ResourceInfo{}, req.GetSign())
shares, err := s.sm.ListPublicShares(ctx, user, req.Filters, req.GetSign())
if err != nil {
log.Err(err).Msg("error listing shares")
return &link.ListPublicSharesResponse{
Expand All @@ -250,7 +249,7 @@ func (s *service) UpdatePublicShare(ctx context.Context, req *link.UpdatePublicS
log.Error().Msg("error getting user from context")
}

updateR, err := s.sm.UpdatePublicShare(ctx, u, req, nil)
updateR, err := s.sm.UpdatePublicShare(ctx, u, req)
if err != nil {
log.Err(err).Msgf("error updating public shares: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cbox/publicshare/sql/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (m *manager) CreatePublicShare(ctx context.Context, u *user.User, rInfo *pr
}, nil
}

func (m *manager) UpdatePublicShare(ctx context.Context, u *user.User, req *link.UpdatePublicShareRequest, g *link.Grant) (*link.PublicShare, error) {
func (m *manager) UpdatePublicShare(ctx context.Context, u *user.User, req *link.UpdatePublicShareRequest) (*link.PublicShare, error) {
query := "update oc_share set "
paramsMap := map[string]interface{}{}
params := []interface{}{}
Expand Down Expand Up @@ -308,7 +308,7 @@ func (m *manager) GetPublicShare(ctx context.Context, u *user.User, ref *link.Pu
return s, nil
}

func (m *manager) ListPublicShares(ctx context.Context, u *user.User, filters []*link.ListPublicSharesRequest_Filter, md *provider.ResourceInfo, sign bool) ([]*link.PublicShare, error) {
func (m *manager) ListPublicShares(ctx context.Context, u *user.User, filters []*link.ListPublicSharesRequest_Filter, sign bool) ([]*link.PublicShare, error) {
uid := conversions.FormatUserID(u.Id)
query := "select coalesce(uid_owner, '') as uid_owner, coalesce(uid_initiator, '') as uid_initiator, coalesce(share_with, '') as share_with, coalesce(fileid_prefix, '') as fileid_prefix, coalesce(item_source, '') as item_source, coalesce(item_type, '') as item_type, coalesce(token,'') as token, coalesce(expiration, '') as expiration, coalesce(share_name, '') as share_name, id, stime, permissions FROM oc_share WHERE (orphan = 0 or orphan IS NULL) AND (uid_owner=? or uid_initiator=?) AND (share_type=?)"
var filterQuery string
Expand Down
Loading

0 comments on commit 58de124

Please sign in to comment.