From ec5211e1f4155eed833f24c1a6d8fb7f18708e0b Mon Sep 17 00:00:00 2001 From: Gianmaria Del Monte Date: Wed, 14 Feb 2024 11:59:53 +0100 Subject: [PATCH] make shares ids uniform with latest changes --- internal/http/services/owncloud/ocgraph/drives.go | 8 ++------ .../owncloud/ocs/handlers/apps/sharing/shares/shares.go | 5 ++--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/internal/http/services/owncloud/ocgraph/drives.go b/internal/http/services/owncloud/ocgraph/drives.go index a2a7572d83..ef28d16818 100644 --- a/internal/http/services/owncloud/ocgraph/drives.go +++ b/internal/http/services/owncloud/ocgraph/drives.go @@ -22,7 +22,6 @@ package ocgraph import ( "context" - "encoding/base32" "encoding/json" "fmt" "net/http" @@ -42,7 +41,6 @@ import ( "github.com/cs3org/reva/pkg/rhttp/router" "github.com/cs3org/reva/pkg/spaces" "github.com/cs3org/reva/pkg/utils/list" - "github.com/cs3org/reva/pkg/utils/resourceid" libregraph "github.com/owncloud/libre-graph-api-go" "github.com/pkg/errors" ) @@ -181,8 +179,6 @@ func convertShareToSpace(ctx context.Context, gw gateway.GatewayAPIClient, share } // the prefix of the remote_item.id and rootid - idPrefix := base32.StdEncoding.EncodeToString([]byte(stat.Info.Path)) - resourceIdEnc := base32.StdEncoding.EncodeToString([]byte(resourceid.OwnCloudResourceIDWrap(stat.Info.Id))) space := &libregraph.Drive{ Id: libregraph.PtrString(fmt.Sprintf("%s$%s!%s", shareJailID, shareJailID, share.Id.OpaqueId)), @@ -197,13 +193,13 @@ func convertShareToSpace(ctx context.Context, gw gateway.GatewayAPIClient, share Folder: &libregraph.Folder{}, // The Id must correspond to the id in the OCS response, for the time being // It is in the form ! - Id: libregraph.PtrString(fmt.Sprintf("%s!%s", idPrefix, resourceIdEnc)), + Id: libregraph.PtrString(spaces.EncodeResourceID(stat.Info.Id)), LastModifiedDateTime: libregraph.PtrTime(time.Unix(int64(stat.Info.Mtime.Seconds), int64(stat.Info.Mtime.Nanos))), Name: libregraph.PtrString(filepath.Base(stat.Info.Path)), Path: libregraph.PtrString("/"), // RootId must have the same token before ! as Id // the second part for the time being is not important - RootId: libregraph.PtrString(fmt.Sprintf("%s!wrong_root_id", idPrefix)), + RootId: libregraph.PtrString(fmt.Sprintf("%s!wrong_root_id", spaces.EncodeSpaceID(stat.Info.Id.StorageId, stat.Info.Id.SpaceId))), Size: libregraph.PtrInt64(int64(stat.Info.Size)), }, }, diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go index 631c71bcc4..3847c67e43 100644 --- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go +++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go @@ -21,7 +21,6 @@ package shares import ( "bytes" "context" - "encoding/base32" "encoding/json" "fmt" "mime" @@ -49,6 +48,7 @@ import ( "github.com/cs3org/reva/internal/http/services/owncloud/ocs/conversions" "github.com/cs3org/reva/internal/http/services/owncloud/ocs/response" "github.com/cs3org/reva/pkg/appctx" + "github.com/cs3org/reva/pkg/spaces" "github.com/cs3org/reva/pkg/notification" "github.com/cs3org/reva/pkg/notification/notificationhelper" @@ -1147,8 +1147,7 @@ func (h *Handler) addFileInfo(ctx context.Context, s *conversions.ShareData, inf s.MimeType = parsedMt // TODO STime: &types.Timestamp{Seconds: info.Mtime.Seconds, Nanos: info.Mtime.Nanos}, // TODO Storage: int - itemID := base32.StdEncoding.EncodeToString([]byte(info.Path)) - itemID += "!" + base32.StdEncoding.EncodeToString([]byte(resourceid.OwnCloudResourceIDWrap(info.Id))) + itemID := spaces.EncodeResourceID(info.Id) s.ItemSource = itemID s.FileSource = s.ItemSource