From 6ac2dfaa17c16cb246668250147aaaeae3b2cc9a Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Sun, 13 Feb 2022 21:05:41 +0100 Subject: [PATCH 1/4] fix bug, coowners are now managers --- internal/http/services/owncloud/ocs/conversions/role.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/http/services/owncloud/ocs/conversions/role.go b/internal/http/services/owncloud/ocs/conversions/role.go index f04bd7cabd..956d0765ce 100644 --- a/internal/http/services/owncloud/ocs/conversions/role.go +++ b/internal/http/services/owncloud/ocs/conversions/role.go @@ -284,12 +284,12 @@ func NewManagerRole() *Role { } } -// RoleFromOCSPermissions tries to map ocs permissions to a role +// RoleFromOCSPermissions tries to map ocs permissions to a role func RoleFromOCSPermissions(p Permissions) *Role { if p.Contain(PermissionRead) { if p.Contain(PermissionWrite) && p.Contain(PermissionCreate) && p.Contain(PermissionDelete) { if p.Contain(PermissionShare) { - return NewCoownerRole() + return NewManagerRole() } return NewEditorRole() } From 031948ebf974c16172605a22ba80f6310a9e2664 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Sun, 13 Feb 2022 21:07:07 +0100 Subject: [PATCH 2/4] choose space description on creation --- pkg/storage/utils/decomposedfs/spaces.go | 53 +++++++++++++----------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/pkg/storage/utils/decomposedfs/spaces.go b/pkg/storage/utils/decomposedfs/spaces.go index b847bd3ce4..4d5d642bb0 100644 --- a/pkg/storage/utils/decomposedfs/spaces.go +++ b/pkg/storage/utils/decomposedfs/spaces.go @@ -67,6 +67,13 @@ func (fs *Decomposedfs) CreateStorageSpace(ctx context.Context, req *provider.Cr spaceID = string(e.Value) } } + // allow sending a space description + var description string + if req.Opaque != nil && req.Opaque.Map != nil { + if e, ok := req.Opaque.Map["description"]; ok && e.Decoder == "plain" { + description = string(e.Value) + } + } // TODO enforce a uuid? // TODO clarify if we want to enforce a single personal storage space or if we want to allow sending the spaceid if req.Type == "personal" { @@ -111,40 +118,27 @@ func (fs *Decomposedfs) CreateStorageSpace(ctx context.Context, req *provider.Cr return nil, err } + metadata := make(map[string]string, 3) if q := req.GetQuota(); q != nil { // set default space quota - if err := n.SetMetadata(xattrs.QuotaAttr, strconv.FormatUint(q.QuotaMaxBytes, 10)); err != nil { - return nil, err - } + metadata[xattrs.QuotaAttr] = strconv.FormatUint(q.QuotaMaxBytes, 10) } - if err := n.SetMetadata(xattrs.SpaceNameAttr, req.Name); err != nil { - return nil, err + metadata[xattrs.SpaceNameAttr] = req.Name + if description != "" { + metadata[xattrs.SpaceDescriptionAttr] = description } - - resp := &provider.CreateStorageSpaceResponse{ - Status: &v1beta11.Status{ - Code: v1beta11.Code_CODE_OK, - }, - StorageSpace: &provider.StorageSpace{ - Owner: u, - Id: &provider.StorageSpaceId{ - OpaqueId: spaceID, - }, - Root: &provider.ResourceId{ - StorageId: spaceID, - OpaqueId: spaceID, - }, - Name: req.GetName(), - Quota: req.GetQuota(), - SpaceType: req.GetType(), - }, + if err := xattrs.SetMultiple(n.InternalPath(), metadata); err != nil { + return nil, err } ctx = context.WithValue(ctx, utils.SpaceGrant, struct{}{}) if err := fs.AddGrant(ctx, &provider.Reference{ - ResourceId: resp.StorageSpace.Root, + ResourceId: &provider.ResourceId{ + StorageId: spaceID, + OpaqueId: spaceID, + }, }, &provider.Grant{ Grantee: &provider.Grantee{ Type: provider.GranteeType_GRANTEE_TYPE_USER, @@ -157,6 +151,17 @@ func (fs *Decomposedfs) CreateStorageSpace(ctx context.Context, req *provider.Cr return nil, err } + space, err := fs.storageSpaceFromNode(ctx, n, "*", n.InternalPath(), false) + if err != nil { + return nil, err + } + + resp := &provider.CreateStorageSpaceResponse{ + Status: &v1beta11.Status{ + Code: v1beta11.Code_CODE_OK, + }, + StorageSpace: space, + } return resp, nil } From 5023db9cf01f8c7b323a01d3ac189f336e58fef5 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Sun, 13 Feb 2022 21:13:43 +0100 Subject: [PATCH 3/4] add changelog Signed-off-by: Michael Barz --- .../change-use-description-during-space-creation.md | 5 +++++ internal/http/services/owncloud/ocs/conversions/role.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/change-use-description-during-space-creation.md diff --git a/changelog/unreleased/change-use-description-during-space-creation.md b/changelog/unreleased/change-use-description-during-space-creation.md new file mode 100644 index 0000000000..0045dda01d --- /dev/null +++ b/changelog/unreleased/change-use-description-during-space-creation.md @@ -0,0 +1,5 @@ +Change: Use description during space creation + +We can now use a space description during space creation. We also fixed a bug in the spaces roles. Co-owners are now maintainers. + +https://github.com/cs3org/reva/pull/2524 diff --git a/internal/http/services/owncloud/ocs/conversions/role.go b/internal/http/services/owncloud/ocs/conversions/role.go index 956d0765ce..9440756040 100644 --- a/internal/http/services/owncloud/ocs/conversions/role.go +++ b/internal/http/services/owncloud/ocs/conversions/role.go @@ -284,7 +284,7 @@ func NewManagerRole() *Role { } } -// RoleFromOCSPermissions tries to map ocs permissions to a role +// RoleFromOCSPermissions tries to map ocs permissions to a role func RoleFromOCSPermissions(p Permissions) *Role { if p.Contain(PermissionRead) { if p.Contain(PermissionWrite) && p.Contain(PermissionCreate) && p.Contain(PermissionDelete) { From 844ba58be09af3424025cf68a75cb6fa7a20059b Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Mon, 14 Feb 2022 08:30:21 +0100 Subject: [PATCH 4/4] fix unit tests --- .../http/services/owncloud/ocs/conversions/permissions_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/http/services/owncloud/ocs/conversions/permissions_test.go b/internal/http/services/owncloud/ocs/conversions/permissions_test.go index 6604b8deb9..ec09a32b7b 100644 --- a/internal/http/services/owncloud/ocs/conversions/permissions_test.go +++ b/internal/http/services/owncloud/ocs/conversions/permissions_test.go @@ -145,7 +145,7 @@ func TestPermissions2Role(t *testing.T) { table := map[Permissions]string{ PermissionRead: RoleViewer, PermissionRead | PermissionWrite | PermissionCreate | PermissionDelete: RoleEditor, - PermissionAll: RoleCoowner, + PermissionAll: RoleManager, PermissionWrite: RoleLegacy, PermissionShare: RoleLegacy, PermissionWrite | PermissionShare: RoleLegacy,