Skip to content

Commit

Permalink
Merge pull request #3648 from owncloud/new-space-id-functions
Browse files Browse the repository at this point in the history
[full-ci] use new space ID util functions
  • Loading branch information
David Christofas authored May 3, 2022
2 parents a6c2956 + 958b4fe commit 5a36f8f
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 34 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/new-space-id-functions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Change: Use new space ID util functions

Changed code to use the new space ID util functions so that everything works with the new spaces ID format.

https://github.com/owncloud/ocis/pull/3648
4 changes: 2 additions & 2 deletions extensions/audit/pkg/types/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

"github.com/cs3org/reva/v2/pkg/events"
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/cs3org/reva/v2/pkg/storagespace"

group "github.com/cs3org/go-cs3apis/cs3/identity/group/v1beta1"
user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
Expand Down Expand Up @@ -453,7 +453,7 @@ func extractFileDetails(ref *provider.Reference, owner *user.UserId) (string, st
id, path := "", ""
if ref != nil {
path = ref.GetPath()
id, _ = utils.FormatStorageSpaceReference(ref)
id, _ = storagespace.FormatReference(ref)
}

uid := ""
Expand Down
11 changes: 6 additions & 5 deletions extensions/graph/pkg/service/v0/driveitems.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
cs3rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
storageprovider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
"github.com/cs3org/reva/v2/pkg/utils/resourceid"
"github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/go-chi/render"
libregraph "github.com/owncloud/libre-graph-api-go"
"github.com/owncloud/ocis/extensions/graph/pkg/service/v0/errorcode"
Expand Down Expand Up @@ -113,7 +113,7 @@ func (g Graph) getRemoteItem(ctx context.Context, root *storageprovider.Resource
return nil, err
}

item.WebDavUrl = libregraph.PtrString(baseURL.String() + resourceid.OwnCloudResourceIDWrap(root))
item.WebDavUrl = libregraph.PtrString(baseURL.String() + storagespace.FormatResourceID(*root))
return item, nil
}

Expand All @@ -139,7 +139,7 @@ func cs3ResourceToDriveItem(res *storageprovider.ResourceInfo) (*libregraph.Driv
*size = int64(res.Size) // TODO lurking overflow: make size of libregraph drive item use uint64

driveItem := &libregraph.DriveItem{
Id: libregraph.PtrString(resourceid.OwnCloudResourceIDWrap(res.Id)),
Id: libregraph.PtrString(storagespace.FormatResourceID(*res.Id)),
Size: size,
}

Expand Down Expand Up @@ -170,7 +170,7 @@ func cs3ResourceToRemoteItem(res *storageprovider.ResourceInfo) (*libregraph.Rem
*size = int64(res.Size) // TODO lurking overflow: make size of libregraph drive item use uint64

remoteItem := &libregraph.RemoteItem{
Id: libregraph.PtrString(resourceid.OwnCloudResourceIDWrap(res.Id)),
Id: libregraph.PtrString(storagespace.FormatResourceID(*res.Id)),
Size: size,
}

Expand Down Expand Up @@ -219,7 +219,8 @@ func (g Graph) GetExtendedSpaceProperties(ctx context.Context, baseURL *url.URL,

for _, itemName := range names {
if itemID, ok := metadata[itemName]; ok {
spaceItem := g.getSpecialDriveItem(ctx, *resourceid.OwnCloudResourceIDUnwrap(string(itemID.Value)), itemName, baseURL, space)
rid, _ := storagespace.ParseID(string(itemID.Value))
spaceItem := g.getSpecialDriveItem(ctx, rid, itemName, baseURL, space)
if spaceItem != nil {
spaceItems = append(spaceItems, *spaceItem)
}
Expand Down
10 changes: 5 additions & 5 deletions extensions/graph/pkg/service/v0/drives.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
storageprovider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
ctxpkg "github.com/cs3org/reva/v2/pkg/ctx"
"github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/cs3org/reva/v2/pkg/utils/resourceid"
"github.com/go-chi/chi/v5"
"github.com/go-chi/render"
libregraph "github.com/owncloud/libre-graph-api-go"
Expand Down Expand Up @@ -287,7 +287,7 @@ func (g Graph) UpdateDrive(w http.ResponseWriter, r *http.Request) {
identifierParts := strings.Split(driveID, "!")
switch len(identifierParts) {
case 1:
sID, _ := resourceid.StorageIDUnwrap(identifierParts[0])
_, sID := storagespace.SplitStorageID(identifierParts[0])
root.StorageId, root.OpaqueId = identifierParts[0], sID
case 2:
root.StorageId, root.OpaqueId = identifierParts[0], identifierParts[1]
Expand Down Expand Up @@ -453,7 +453,7 @@ func generateSpaceId(id *storageprovider.ResourceId) (spaceID string) {
// 2nd ID to compare is the opaque ID of the Space Root
spaceID2 := id.GetOpaqueId()
if strings.Contains(spaceID, "$") {
spaceID2, _ = resourceid.StorageIDUnwrap(spaceID)
_, spaceID2 = storagespace.SplitStorageID(spaceID)
}
// Append opaqueID only if it is different from the spaceID2
if id.OpaqueId != spaceID2 {
Expand Down Expand Up @@ -531,7 +531,7 @@ func (g Graph) cs3StorageSpaceToDrive(ctx context.Context, baseURL *url.URL, spa
//"description": "string", // TODO read from StorageSpace ... needs Opaque for now
DriveType: &space.SpaceType,
Root: &libregraph.DriveItem{
Id: libregraph.PtrString(resourceid.OwnCloudResourceIDWrap(space.Root)),
Id: libregraph.PtrString(storagespace.FormatResourceID(*space.Root)),
Permissions: permissions,
},
}
Expand Down Expand Up @@ -764,7 +764,7 @@ func (g Graph) DeleteDrive(w http.ResponseWriter, r *http.Request) {
root := &storageprovider.ResourceId{}

identifierParts := strings.Split(driveID, "!")
sID, _ := resourceid.StorageIDUnwrap(identifierParts[0])
_, sID := storagespace.SplitStorageID(identifierParts[0])
switch len(identifierParts) {
case 1:
root.StorageId, root.OpaqueId = identifierParts[0], sID
Expand Down
13 changes: 5 additions & 8 deletions extensions/thumbnails/pkg/service/grpc/v0/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
revactx "github.com/cs3org/reva/v2/pkg/ctx"
"github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/golang-jwt/jwt/v4"
"github.com/owncloud/ocis/extensions/thumbnails/pkg/preprocessor"
"github.com/owncloud/ocis/extensions/thumbnails/pkg/service/grpc/v0/decorators"
Expand Down Expand Up @@ -257,15 +258,11 @@ func (g Thumbnail) stat(path, auth string) (*provider.StatResponse, error) {

var ref *provider.Reference
if strings.Contains(path, "!") {
parts := strings.Split(path, "!")
spaceID, path := parts[0], parts[1]
ref = &provider.Reference{
ResourceId: &provider.ResourceId{
StorageId: spaceID,
OpaqueId: spaceID,
},
Path: path,
parsed, err := storagespace.ParseReference(path)
if err != nil {
return nil, err
}
ref = &parsed
} else {
ref = &provider.Reference{
Path: path,
Expand Down
14 changes: 5 additions & 9 deletions extensions/thumbnails/pkg/thumbnail/imgsource/cs3.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
revactx "github.com/cs3org/reva/v2/pkg/ctx"
"github.com/cs3org/reva/v2/pkg/rhttp"
"github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/owncloud/ocis/extensions/thumbnails/pkg/config"
"github.com/pkg/errors"
"google.golang.org/grpc/metadata"
Expand Down Expand Up @@ -45,16 +46,11 @@ func (s CS3) Get(ctx context.Context, path string) (io.ReadCloser, error) {
}
var ref *provider.Reference
if strings.Contains(path, "!") {
parts := strings.Split(path, "!")
spaceID, path := parts[0], parts[1]
ref = &provider.Reference{
ResourceId: &provider.ResourceId{
StorageId: spaceID,
OpaqueId: spaceID,
},
// Spaces requests need relative paths.
Path: "." + path,
parsed, err := storagespace.ParseReference(path)
if err != nil {
return nil, err
}
ref = &parsed
} else {
ref = &provider.Reference{
Path: path,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/blevesearch/bleve_index_api v1.0.1
github.com/coreos/go-oidc/v3 v3.1.0
github.com/cs3org/go-cs3apis v0.0.0-20220412090512-93c5918b4bde
github.com/cs3org/reva/v2 v2.0.0-20220503062800-28d8d2578a8f
github.com/cs3org/reva/v2 v2.0.0-20220503122729-afc8ead0c9a6
github.com/disintegration/imaging v1.6.2
github.com/glauth/glauth/v2 v2.0.0-20211021011345-ef3151c28733
github.com/go-chi/chi/v5 v5.0.7
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBW
github.com/boombuler/barcode v1.0.1 h1:NDBbPmhS+EqABEs5Kg3n/5ZNjy73Pz7SIV+KCeqyXcs=
github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/c-bata/go-prompt v0.2.5/go.mod h1:vFnjEGDIIA/Lib7giyE4E9c50Lvl8j0S+7FVlAwDAVw=
github.com/c0rby/reva/v2 v2.0.0-20220502195635-b3d192b975d0 h1:r4XeggvJMiYTugpgmPsOWF/ulRFUHOj/oWep/5Q+xZY=
github.com/c0rby/reva/v2 v2.0.0-20220502195635-b3d192b975d0/go.mod h1:2e/4HcIy54Mic3V7Ow0bz4n5dkZU0dHIZSWomFe5vng=
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/cenkalti/backoff/v4 v4.1.0/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
Expand Down Expand Up @@ -318,10 +320,8 @@ github.com/cs3org/go-cs3apis v0.0.0-20220412090512-93c5918b4bde h1:WrD9O8ZaWvsm0
github.com/cs3org/go-cs3apis v0.0.0-20220412090512-93c5918b4bde/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
github.com/cs3org/reva v1.18.0 h1:MbPS5ZAa8RzKcTxAVeSDdISB3XXqLIxqB03BTN5ReBY=
github.com/cs3org/reva v1.18.0/go.mod h1:e5VDUDu4vVWIeVkZcW//n6UZzhGGMa+Tz/whCiX3N6o=
github.com/cs3org/reva/v2 v2.0.0-20220502122639-bfbf8690a043 h1:wAvf45pBDnWIN4kpyWpD9uRl9y147ioAXJkfztrMSCM=
github.com/cs3org/reva/v2 v2.0.0-20220502122639-bfbf8690a043/go.mod h1:2e/4HcIy54Mic3V7Ow0bz4n5dkZU0dHIZSWomFe5vng=
github.com/cs3org/reva/v2 v2.0.0-20220503062800-28d8d2578a8f h1:3ge1ufZLjNni3FftOucKd0h9k9SGqzVoNnQ4Ssr03gQ=
github.com/cs3org/reva/v2 v2.0.0-20220503062800-28d8d2578a8f/go.mod h1:2e/4HcIy54Mic3V7Ow0bz4n5dkZU0dHIZSWomFe5vng=
github.com/cs3org/reva/v2 v2.0.0-20220503122729-afc8ead0c9a6 h1:7NmN0CkDNS+YDFPvT+n73f8WJHkRVG3OmPnOwWNPdlM=
github.com/cs3org/reva/v2 v2.0.0-20220503122729-afc8ead0c9a6/go.mod h1:2e/4HcIy54Mic3V7Ow0bz4n5dkZU0dHIZSWomFe5vng=
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI=
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8/go.mod h1:4abs/jPXcmJzYoYGF91JF9Uq9s/KL5n1jvFDix8KcqY=
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
Expand Down

0 comments on commit 5a36f8f

Please sign in to comment.