Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[full-ci] Unify id format #3185

Merged
merged 7 commits into from
Feb 17, 2022
Merged

[full-ci] Unify id format #3185

merged 7 commits into from
Feb 17, 2022

Conversation

micbar
Copy link
Contributor

@micbar micbar commented Feb 16, 2022

Description

Change: Unify file IDs

We changed the file IDs to be consistent across all our APIs (WebDAV, LibreGraph, OCS). We removed the base64 encoding. Now they are formatted like <storageID>!<opaqueID>. They are using a reserved character ! as a URL safe separator.

Related Issue

Reva PR cs3org/reva#2542

Motivation and Context

FileIDs should be consistent across all APIs

How Has This Been Tested?

  • Manually
  • CI

Examples:

WebDAV

curl -L -X PROPFIND 'https://localhost:9200/dav/spaces/6afcb97a-e632-447d-b832-1334a8a9634f' \
-H 'Depth: infinity' \
-H 'Authorization: Basic YWRtaW46YWRtaW4='
<d:multistatus xmlns:s="http://sabredav.org/ns" xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
    <d:response>
        <d:href>/dav/spaces/6afcb97a-e632-447d-b832-1334a8a9634f/</d:href>
        <d:propstat>
            <d:prop>
                <oc:id>6afcb97a-e632-447d-b832-1334a8a9634f!6afcb97a-e632-447d-b832-1334a8a9634f</oc:id>
                <oc:fileid>6afcb97a-e632-447d-b832-1334a8a9634f!6afcb97a-e632-447d-b832-1334a8a9634f</oc:fileid>
                <d:getetag>&#34;55e95f454e48c0047d901686f4f7027c&#34;</d:getetag>
                <oc:permissions>RDNVCK</oc:permissions>
                <d:resourcetype>
                    <d:collection/>
                </d:resourcetype>
                <oc:size>2019472</oc:size>
                <d:getlastmodified>Tue, 15 Feb 2022 11:42:10 GMT</d:getlastmodified>
                <oc:favorite>0</oc:favorite>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response>
    <d:response>
        <d:href>/dav/spaces/6afcb97a-e632-447d-b832-1334a8a9634f/Space_Image.jpg</d:href>
        <d:propstat>
            <d:prop>
                <oc:id>6afcb97a-e632-447d-b832-1334a8a9634f!83a2c6ab-19f2-4f51-b3cb-41aef54ee5ab</oc:id>
                <oc:fileid>6afcb97a-e632-447d-b832-1334a8a9634f!83a2c6ab-19f2-4f51-b3cb-41aef54ee5ab</oc:fileid>
                <d:getetag>&#34;0440204b65664c18fa73a40cfe625815&#34;</d:getetag>
                <oc:permissions>RDNVW</oc:permissions>
                <d:resourcetype></d:resourcetype>
                <d:getcontentlength>2019367</d:getcontentlength>
                <d:getcontenttype>image/jpeg</d:getcontenttype>
                <d:getlastmodified>Tue, 15 Feb 2022 11:42:10 GMT</d:getlastmodified>
                <oc:checksums>
                    <oc:checksum>SHA1:439c4a6de0489288bb88914913fd1e5ece7d1764 MD5:2540f4e8f934296b617973f1a5cd5ae3 ADLER32:1c056526</oc:checksum>
                </oc:checksums>
                <oc:favorite>0</oc:favorite>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response>
    <d:response>
        <d:href>/dav/spaces/6afcb97a-e632-447d-b832-1334a8a9634f/NewFile5.md</d:href>
        <d:propstat>
            <d:prop>
                <oc:id>6afcb97a-e632-447d-b832-1334a8a9634f!44b8c8ba-8f57-452f-9b28-85b2058bdac8</oc:id>
                <oc:fileid>6afcb97a-e632-447d-b832-1334a8a9634f!44b8c8ba-8f57-452f-9b28-85b2058bdac8</oc:fileid>
                <d:getetag>&#34;6f35041017b213007453cd8d74ccb331&#34;</d:getetag>
                <oc:permissions>RDNVW</oc:permissions>
                <d:resourcetype></d:resourcetype>
                <d:getcontentlength>105</d:getcontentlength>
                <d:getcontenttype>text/markdown</d:getcontenttype>
                <d:getlastmodified>Tue, 15 Feb 2022 11:41:34 GMT</d:getlastmodified>
                <oc:checksums>
                    <oc:checksum>SHA1:081272bd25665a1a884fd50f3143220411c6e8a3 MD5:9bdb7fc99749fb9b2207358aec781742 ADLER32:dd6928f0</oc:checksum>
                </oc:checksums>
                <oc:favorite>0</oc:favorite>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response>
    <d:response>
        <d:href>/dav/spaces/6afcb97a-e632-447d-b832-1334a8a9634f/NewFolder/</d:href>
        <d:propstat>
            <d:prop>
                <oc:id>6afcb97a-e632-447d-b832-1334a8a9634f!dc4399c7-1fed-46e1-b81d-36c3db1c74ba</oc:id>
                <oc:fileid>6afcb97a-e632-447d-b832-1334a8a9634f!dc4399c7-1fed-46e1-b81d-36c3db1c74ba</oc:fileid>
                <d:getetag>&#34;0e0ec707e062c806e5e48faefcdca725&#34;</d:getetag>
                <oc:permissions>RDNVCK</oc:permissions>
                <d:resourcetype>
                    <d:collection/>
                </d:resourcetype>
                <oc:size>0</oc:size>
                <d:getlastmodified>Tue, 15 Feb 2022 11:40:51 GMT</d:getlastmodified>
                <oc:favorite>0</oc:favorite>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response>
</d:multistatus>

GraphAPI

curl -L -X GET 'https://localhost:9200/graph/v1.0/me/drives/?$filter=id eq '\''6afcb97a-e632-447d-b832-1334a8a9634f'\''' \
-H 'Authorization: Basic YWRtaW46YWRtaW4='
{
    "value": [
        {
            "description": "USS Enterprise D",
            "driveType": "project",
            "id": "6afcb97a-e632-447d-b832-1334a8a9634f",
            "lastModifiedDateTime": "2022-02-15T12:42:10.508053+01:00",
            "name": "Project Spaceship",
            "quota": {
                "remaining": 997980528,
                "state": "normal",
                "total": 1000000000,
                "used": 2019472
            },
            "root": {
                "id": "6afcb97a-e632-447d-b832-1334a8a9634f!6afcb97a-e632-447d-b832-1334a8a9634f",
                "permissions": [
                    {
                        "grantedTo": [
                            {
                                "user": {
                                    "id": "ddc2004c-0977-11eb-9d3f-a793888cd0f8"
                                }
                            },
                            {
                                "user": {
                                    "id": "f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c"
                                }
                            }
                        ],
                        "roles": [
                            "manager"
                        ]
                    }
                ],
                "webDavUrl": "https://localhost:9200/dav/spaces/6afcb97a-e632-447d-b832-1334a8a9634f"
            },
            "special": [
                {
                    "eTag": "\"0440204b65664c18fa73a40cfe625815\"",
                    "file": {
                        "mimeType": "image/jpeg"
                    },
                    "id": "6afcb97a-e632-447d-b832-1334a8a9634f!83a2c6ab-19f2-4f51-b3cb-41aef54ee5ab",
                    "lastModifiedDateTime": "2022-02-15T12:42:10.507576189+01:00",
                    "name": "Space_Image.jpg",
                    "size": 2019367,
                    "specialFolder": {
                        "name": "image"
                    },
                    "webDavUrl": "https://localhost:9200/dav/spaces/6afcb97a-e632-447d-b832-1334a8a9634f/Space_Image.jpg"
                },
                {
                    "eTag": "\"6f35041017b213007453cd8d74ccb331\"",
                    "file": {
                        "mimeType": "text/markdown"
                    },
                    "id": "6afcb97a-e632-447d-b832-1334a8a9634f!44b8c8ba-8f57-452f-9b28-85b2058bdac8",
                    "lastModifiedDateTime": "2022-02-15T12:41:34.435893364+01:00",
                    "name": "NewFile5.md",
                    "size": 105,
                    "specialFolder": {
                        "name": "readme"
                    },
                    "webDavUrl": "https://localhost:9200/dav/spaces/6afcb97a-e632-447d-b832-1334a8a9634f/NewFile5.md"
                }
            ]
        }
    ]
}

GraphAPI (Set Space Image)

curl -L -X PATCH 'https://localhost:9200/graph/v1.0/drives/6afcb97a-e632-447d-b832-1334a8a9634f' \
-H 'Authorization: Basic YWRtaW46YWRtaW4=' \
-H 'Content-Type: application/json' \
--data-raw '{
  "description": "Moon over the horizon",
  "special":[
      {
          "specialFolder": {
              "name": "image"
          },
          "id": "6afcb97a-e632-447d-b832-1334a8a9634f!83a2c6ab-19f2-4f51-b3cb-41aef54ee5ab"
      }
  ]
}'
{
    "description": "Moon over the horizon",
    "driveType": "project",
    "id": "6afcb97a-e632-447d-b832-1334a8a9634f",
    "lastModifiedDateTime": "2022-02-15T12:42:10.508053+01:00",
    "name": "Project Spaceship",
    "quota": {
        "remaining": 997980528,
        "state": "normal",
        "total": 1000000000,
        "used": 2019472
    },
    "root": {
        "id": "6afcb97a-e632-447d-b832-1334a8a9634f!6afcb97a-e632-447d-b832-1334a8a9634f",
        "permissions": [
            {
                "grantedTo": [
                    {
                        "user": {
                            "id": "f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c"
                        }
                    },
                    {
                        "user": {
                            "id": "ddc2004c-0977-11eb-9d3f-a793888cd0f8"
                        }
                    }
                ],
                "roles": [
                    "manager"
                ]
            }
        ],
        "webDavUrl": "https://localhost:9200/dav/spaces/6afcb97a-e632-447d-b832-1334a8a9634f"
    },
    "special": [
        {
            "eTag": "\"0440204b65664c18fa73a40cfe625815\"",
            "file": {
                "mimeType": "image/jpeg"
            },
            "id": "6afcb97a-e632-447d-b832-1334a8a9634f!83a2c6ab-19f2-4f51-b3cb-41aef54ee5ab",
            "lastModifiedDateTime": "2022-02-15T12:42:10.507576189+01:00",
            "name": "Space_Image.jpg",
            "size": 2019367,
            "specialFolder": {
                "name": "image"
            },
            "webDavUrl": "https://localhost:9200/dav/spaces/6afcb97a-e632-447d-b832-1334a8a9634f/Space_Image.jpg"
        },
        {
            "eTag": "\"6f35041017b213007453cd8d74ccb331\"",
            "file": {
                "mimeType": "text/markdown"
            },
            "id": "6afcb97a-e632-447d-b832-1334a8a9634f!44b8c8ba-8f57-452f-9b28-85b2058bdac8",
            "lastModifiedDateTime": "2022-02-15T12:41:34.435893364+01:00",
            "name": "NewFile5.md",
            "size": 105,
            "specialFolder": {
                "name": "readme"
            },
            "webDavUrl": "https://localhost:9200/dav/spaces/6afcb97a-e632-447d-b832-1334a8a9634f/NewFile5.md"
        }
    ]
}

OCS (Add users to spaces)

curl -L -X POST 'https://localhost:9200/ocs/v1.php/apps/files_sharing/api/v1/shares?shareType=7&shareWith=marie&space_ref=6afcb97a-e632-447d-b832-1334a8a9634f!6afcb97a-e632-447d-b832-1334a8a9634f&role=manager' \
-H 'Authorization: Basic YWRtaW46YWRtaW4='

Manual Archiver Test

Bildschirmfoto 2022-02-16 um 21 58 09

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

@micbar micbar marked this pull request as draft February 16, 2022 17:10
@micbar micbar requested review from butonic and C0rby February 16, 2022 17:11
@micbar micbar self-assigned this Feb 16, 2022
@micbar micbar added the Category:Change Change existing functionality label Feb 16, 2022
go.mod Outdated Show resolved Hide resolved
@micbar micbar marked this pull request as ready for review February 16, 2022 20:14
@sonarcloud
Copy link

sonarcloud bot commented Feb 16, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

27.3% 27.3% Coverage
0.0% 0.0% Duplication

@butonic butonic merged commit f0d8b31 into master Feb 17, 2022
@delete-merged-branch delete-merged-branch bot deleted the fix-id branch February 17, 2022 08:39
ownclouders pushed a commit that referenced this pull request Feb 17, 2022
Merge: c2caf38 3ff984e
Author: Jörn Friedrich Dreyer <jfd@owncloud.com>
Date:   Thu Feb 17 09:39:14 2022 +0100

    Merge pull request #3185 from owncloud/fix-id

    [full-ci] Unify id format
@micbar micbar mentioned this pull request Mar 3, 2022
26 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category:Change Change existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants