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/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, diff --git a/internal/http/services/owncloud/ocs/conversions/role.go b/internal/http/services/owncloud/ocs/conversions/role.go index f04bd7cabd..9440756040 100644 --- a/internal/http/services/owncloud/ocs/conversions/role.go +++ b/internal/http/services/owncloud/ocs/conversions/role.go @@ -289,7 +289,7 @@ 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() } 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 }