use id wrap and unwrap from reva

This commit is contained in:
Michael Barz
2022-02-16 17:40:36 +01:00
parent dfc87e59fd
commit 3167377fca
4 changed files with 13 additions and 13 deletions
+2
View File
@@ -266,3 +266,5 @@ require (
// we need to use a fork to make the windows build pass
replace github.com/pkg/xattr => github.com/micbar/xattr v0.4.6-0.20220215112335-88e74d648fb7
replace github.com/cs3org/reva => ../reva
-4
View File
@@ -337,10 +337,6 @@ github.com/crewjam/saml v0.4.5/go.mod h1:qCJQpUtZte9R1ZjUBcW8qtCNlinbO363ooNl02S
github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e/go.mod h1:XJEZ3/EQuI3BXTp/6DUzFr850vlxq11I6satRtz0YQ4=
github.com/cs3org/go-cs3apis v0.0.0-20220126114148-64c025ccdd19 h1:1jqPH58jCxvbaJ9WLIJ7W2/m622bWS6ChptzljSG6IQ=
github.com/cs3org/go-cs3apis v0.0.0-20220126114148-64c025ccdd19/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
github.com/cs3org/reva v1.16.1-0.20220214105747-d217886c962b h1:E53EHbKiHIIJeZgDEx5tE3AflxgL1dHughNbBQU7Dfk=
github.com/cs3org/reva v1.16.1-0.20220214105747-d217886c962b/go.mod h1:gdKuhou74V47snANuHNIhGNJfCKUSCHPPvuhSx7nu5M=
github.com/cs3org/reva v1.16.1-0.20220215130802-df1264deff58 h1:CBSpClYZp8Q7Cl/xENW42Zy7M9+vqACAulqXFnWn3Ug=
github.com/cs3org/reva v1.16.1-0.20220215130802-df1264deff58/go.mod h1:gdKuhou74V47snANuHNIhGNJfCKUSCHPPvuhSx7nu5M=
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=
+9 -8
View File
@@ -11,6 +11,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/pkg/utils/resourceid"
"github.com/go-chi/render"
libregraph "github.com/owncloud/libre-graph-api-go"
"github.com/owncloud/ocis/graph/pkg/service/v0/errorcode"
@@ -113,7 +114,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: &res.Id.OpaqueId,
Id: libregraph.PtrString(resourceid.OwnCloudResourceIDWrap(res.Id)),
Size: size,
}
@@ -164,7 +165,7 @@ func (g Graph) GetExtendedSpaceProperties(ctx context.Context, baseURL *url.URL,
for _, itemName := range names {
if itemID, ok := metadata[itemName]; ok {
spaceItem := g.getSpecialDriveItem(ctx, string(itemID.Value), itemName, baseURL, space)
spaceItem := g.getSpecialDriveItem(ctx, resourceid.OwnCloudResourceIDUnwrap(string(itemID.Value)), itemName, baseURL, space)
if spaceItem != nil {
spaceItems = append(spaceItems, *spaceItem)
}
@@ -173,20 +174,20 @@ func (g Graph) GetExtendedSpaceProperties(ctx context.Context, baseURL *url.URL,
return spaceItems
}
func (g Graph) getSpecialDriveItem(ctx context.Context, itemID string, itemName string, baseURL *url.URL, space *storageprovider.StorageSpace) *libregraph.DriveItem {
func (g Graph) getSpecialDriveItem(ctx context.Context, ID *storageprovider.ResourceId, itemName string, baseURL *url.URL, space *storageprovider.StorageSpace) *libregraph.DriveItem {
var spaceItem *libregraph.DriveItem
if itemID == "" {
if ID == nil {
return nil
}
spaceItem, err := g.getDriveItem(ctx, &storageprovider.ResourceId{StorageId: space.Root.StorageId, OpaqueId: itemID})
spaceItem, err := g.getDriveItem(ctx, ID)
if err != nil {
g.logger.Error().Err(err).Str("ID", itemID).Msg("Could not get readme Item")
g.logger.Error().Err(err).Str("ID", ID.OpaqueId).Msg("Could not get readme Item")
return nil
}
itemPath, err := g.getPathForDriveItem(ctx, &storageprovider.ResourceId{StorageId: space.Root.StorageId, OpaqueId: itemID})
itemPath, err := g.getPathForDriveItem(ctx, ID)
if err != nil {
g.logger.Error().Err(err).Str("ID", itemID).Msg("Could not get readme path")
g.logger.Error().Err(err).Str("ID", ID.OpaqueId).Msg("Could not get readme path")
return nil
}
spaceItem.SpecialFolder = &libregraph.SpecialFolder{Name: libregraph.PtrString(itemName)}
+2 -1
View File
@@ -18,6 +18,7 @@ import (
types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
ctxpkg "github.com/cs3org/reva/pkg/ctx"
"github.com/cs3org/reva/pkg/utils"
"github.com/cs3org/reva/pkg/utils/resourceid"
"github.com/go-chi/chi/v5"
"github.com/go-chi/render"
libregraph "github.com/owncloud/libre-graph-api-go"
@@ -409,7 +410,7 @@ func (g Graph) ListStorageSpacesWithFilters(ctx context.Context, filters []*stor
}
func (g Graph) cs3StorageSpaceToDrive(baseURL *url.URL, space *storageprovider.StorageSpace) (*libregraph.Drive, error) {
rootID := space.Root.StorageId + "!" + space.Root.OpaqueId
rootID := resourceid.OwnCloudResourceIDWrap(space.Root)
if space.Root.StorageId == space.Root.OpaqueId {
// omit opaqueid
rootID = space.Root.StorageId