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

Implement a publicshare manager using the metadata storage backend #2644

Merged
merged 24 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f134109
Move Indexer and Storage interfaces to their libraries for reusability
aduffeck Mar 10, 2022
3dcf1df
Fix naming of nested field indexes
aduffeck Mar 11, 2022
872e963
Add initial version of the cs3-based publicshare manager
aduffeck Mar 11, 2022
ea766c3
Cleanup unused parameter
aduffeck Mar 14, 2022
0b075ec
Return empty result instead of error when listed directory doesn't exist
aduffeck Mar 14, 2022
deec946
Implement ListPublicShares
aduffeck Mar 14, 2022
56802c0
Add support for adding signature to the returned public shares
aduffeck Mar 14, 2022
c03a5af
Implement RevokePublicShare
aduffeck Mar 14, 2022
ad2e311
Extract authenticate into the main package for reusability
aduffeck Mar 15, 2022
75149fa
Implement GetPublicShareByToken
aduffeck Mar 15, 2022
1f5a68d
More API cleanup
aduffeck Mar 15, 2022
758723e
Add config and make NewDefault work
aduffeck Mar 15, 2022
bd8b4bd
Implement UpdatePublicShare
aduffeck Mar 15, 2022
d6741a5
Fix rebase artifact
aduffeck Mar 16, 2022
8c143d9
Improve tests
aduffeck Mar 17, 2022
632cf93
Make sure to always initialize the manager
aduffeck Mar 17, 2022
2f7558a
Fix tests
aduffeck Mar 17, 2022
3fb72fb
Return NotFoundErr if there is no match
aduffeck Mar 17, 2022
1d0783e
Linter fixes
aduffeck Mar 17, 2022
6b5defb
Add changelog
aduffeck Mar 17, 2022
a53373d
Make sure to address the proper index
aduffeck Mar 17, 2022
5435c10
Make sure to initialize the manager atomically
aduffeck Mar 17, 2022
5811a33
Fix setting the display name from the metadata
aduffeck Mar 17, 2022
2b63461
Improve style according to review
aduffeck Mar 17, 2022
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/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