Skip to content

Commit

Permalink
Add logic for received shares method
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Oct 6, 2020
1 parent 6a99621 commit e4f31a4
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 116 deletions.
2 changes: 1 addition & 1 deletion changelog/unreleased/eos-version-invariant.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ versions of a file by returning the inode of the version folder which remains
constant. It requires extra metadata operations so a flag is provided to disable
it.

https://github.com/cs3org/reva/pull/1174.
https://github.com/cs3org/reva/pull/1174
6 changes: 6 additions & 0 deletions changelog/unreleased/shares-sql-driver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Add SQL driver for share manager

This PR adds an SQL driver for the shares manager which expects a schema
equivalent to the one used in production for CERNBox.

https://github.com/cs3org/reva/pull/1224
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ require (
github.com/go-ldap/ldap/v3 v3.2.3
github.com/go-openapi/errors v0.19.6 // indirect
github.com/go-openapi/strfmt v0.19.2 // indirect
github.com/go-sql-driver/mysql v1.5.0
github.com/gofrs/uuid v3.3.0+incompatible
github.com/golang/protobuf v1.4.2
github.com/gomodule/redigo v1.8.2
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ github.com/go-openapi/strfmt v0.19.2 h1:clPGfBnJohokno0e+d7hs6Yocrzjlgz6EsQSDncC
github.com/go-openapi/strfmt v0.19.2/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU=
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
Expand Down
1 change: 1 addition & 0 deletions pkg/share/manager/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,5 +452,6 @@ func (m *mgr) UpdateReceivedShare(ctx context.Context, ref *collaboration.ShareR
return nil, err
}

rs.State = f.GetState()
return rs, nil
}
35 changes: 19 additions & 16 deletions pkg/share/manager/sql/conversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
collaboration "github.com/cs3org/go-cs3apis/cs3/sharing/collaboration/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
typespb "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
_ "github.com/go-sql-driver/mysql"
)

func granteeTypeToInt(g provider.GranteeType) int {
Expand Down Expand Up @@ -67,21 +66,6 @@ func resourceTypeToItem(r provider.ResourceType) string {
}
}

func itemToresourceType(r string) provider.ResourceType {
switch r {
case "file":
return provider.ResourceType_RESOURCE_TYPE_FILE
case "folder":
return provider.ResourceType_RESOURCE_TYPE_CONTAINER
case "reference":
return provider.ResourceType_RESOURCE_TYPE_REFERENCE
case "symlink":
return provider.ResourceType_RESOURCE_TYPE_SYMLINK
default:
return provider.ResourceType_RESOURCE_TYPE_INVALID
}
}

func sharePermToInt(p *provider.ResourcePermissions) int {
var perm int
if p.CreateContainer {
Expand Down Expand Up @@ -130,6 +114,17 @@ func intTosharePerm(p int) *provider.ResourcePermissions {
}
}

func intToShareState(g int) collaboration.ShareState {
switch g {
case 0:
return collaboration.ShareState_SHARE_STATE_PENDING
case 1:
return collaboration.ShareState_SHARE_STATE_ACCEPTED
default:
return collaboration.ShareState_SHARE_STATE_INVALID
}
}

func formatUserID(u *userpb.UserId) string {
if u.Idp != "" {
return fmt.Sprintf("%s:%s", u.OpaqueId, u.Idp)
Expand Down Expand Up @@ -162,3 +157,11 @@ func convertToCS3Share(s dbShare) *collaboration.Share {
Mtime: ts,
}
}

func convertToCS3ReceivedShare(s dbShare) *collaboration.ReceivedShare {
share := convertToCS3Share(s)
return &collaboration.ReceivedShare{
Share: share,
State: intToShareState(s.State),
}
}
Loading

0 comments on commit e4f31a4

Please sign in to comment.