handle resource ids better

This commit is contained in:
Michael Barz
2022-04-29 21:31:04 +02:00
parent a86cc5ab3a
commit 78a6af3af5
2 changed files with 7 additions and 3 deletions

View File

@@ -273,7 +273,8 @@ func (g Graph) UpdateDrive(w http.ResponseWriter, r *http.Request) {
identifierParts := strings.Split(driveID, "!")
switch len(identifierParts) {
case 1:
root.StorageId, root.OpaqueId = identifierParts[0], identifierParts[0]
sID, _ := resourceid.StorageIDUnwrap(identifierParts[0])
root.StorageId, root.OpaqueId = identifierParts[0], sID
case 2:
root.StorageId, root.OpaqueId = identifierParts[0], identifierParts[1]
default:
@@ -492,7 +493,8 @@ func (g Graph) cs3StorageSpaceToDrive(ctx context.Context, baseURL *url.URL, spa
}
spaceID := space.Root.StorageId
if space.Root.OpaqueId != space.Root.StorageId {
sIDs := resourceid.OwnCloudResourceIDUnwrap(rootID)
if space.Root.OpaqueId != sIDs.OpaqueId {
spaceID = rootID
}
drive := &libregraph.Drive{
@@ -735,9 +737,10 @@ func (g Graph) DeleteDrive(w http.ResponseWriter, r *http.Request) {
root := &storageprovider.ResourceId{}
identifierParts := strings.Split(driveID, "!")
sID, _ := resourceid.StorageIDUnwrap(identifierParts[0])
switch len(identifierParts) {
case 1:
root.StorageId, root.OpaqueId = identifierParts[0], identifierParts[0]
root.StorageId, root.OpaqueId = identifierParts[0], sID
case 2:
root.StorageId, root.OpaqueId = identifierParts[0], identifierParts[1]
default:

1
go.mod
View File

@@ -274,3 +274,4 @@ 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/v2 => ../reva