handle resource ids better

This commit is contained in:
Michael Barz
2022-05-02 09:53:50 +02:00
parent a86cc5ab3a
commit 78a6af3af5
2 changed files with 7 additions and 3 deletions
+6 -3
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: