Skip to content

fix(sharesstorageprovider): Merge shares of the same resourceid - #4517

Merged
butonic merged 3 commits into
cs3org:edgefrom
rhafer:ocisissue/8080
Feb 21, 2024
Merged

butonic merged 3 commits into
cs3org:edgefrom
rhafer:ocisissue/8080

Conversation

@rhafer

@rhafer rhafer commented Feb 15, 2024

Copy link
Copy Markdown
Contributor

When listing the sharejail root, merge shares that target the same resource into a single resource. In order to avoid the resourceId changing randomly the id will be composed from the oldest accepted share that exist for the resource.

Ideally we'd compose the resourceId based on the id of the shared resource, but that is currently not possible in a backwards compatible way. Some clients seem to rely on the fact that the resource ids in the sharejail contain valid shareids.

Fixes: owncloud/ocis#8080

@rhafer

rhafer commented Feb 20, 2024

Copy link
Copy Markdown
Contributor Author

Example:
The folder New Folder was shared to the user marie and the groups users, physics-lovers, polonium-lovers and radium-lovers, which marie is a member of.

We now only return a single prop item

<?xml version="1.0"?>
<d:multistatus xmlns:s="http://sabredav.org/ns" xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
  <d:response>
    <d:href>/dav/spaces/a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668/</d:href>
    <d:propstat>
      <d:prop>
        <oc:id>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!a0ca6a90-a365-4782-871e-d44447bbc668</oc:id>
        <oc:fileid>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!a0ca6a90-a365-4782-871e-d44447bbc668</oc:fileid>
        <oc:spaceid>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668</oc:spaceid>
        <oc:shareid/>
        <d:getetag>"3eabdd6cdd6786be98ab99dfda0bbdd3"</d:getetag>
        <oc:permissions/>
        <d:resourcetype>
          <d:collection/>
        </d:resourcetype>
        <oc:size>0</oc:size>
        <d:getlastmodified>Tue, 20 Feb 2024 12:15:54 GMT</d:getlastmodified>
        <oc:favorite>0</oc:favorite>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
    <d:propstat>
      <d:prop>
        <oc:file-parent/>
      </d:prop>
      <d:status>HTTP/1.1 404 Not Found</d:status>
    </d:propstat>
  </d:response>
  <d:response>
    <d:href>/dav/spaces/a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668/New%20folder/</d:href>
    <d:propstat>
      <d:prop>
        <oc:id>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!134c39fb-1978-42ee-bf27-c1aea656cedf:354c5a1d-bf13-4d6f-b844-7580c58576fb:55bb6cce-c22a-4af2-9704-6fa62f975a9b</oc:id>
        <oc:fileid>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!134c39fb-1978-42ee-bf27-c1aea656cedf:354c5a1d-bf13-4d6f-b844-7580c58576fb:55bb6cce-c22a-4af2-9704-6fa62f975a9b</oc:fileid>
        <oc:spaceid>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668</oc:spaceid>
        <oc:file-parent>134c39fb-1978-42ee-bf27-c1aea656cedf$354c5a1d-bf13-4d6f-b844-7580c58576fb!354c5a1d-bf13-4d6f-b844-7580c58576fb</oc:file-parent>
        <oc:shareid/>
        <oc:name>New folder</oc:name>
        <d:displayname>New folder</d:displayname>
        <d:getetag>"3eabdd6cdd6786be98ab99dfda0bbdd3"</d:getetag>
        <oc:permissions>SR</oc:permissions>
        <d:resourcetype>
          <d:collection/>
        </d:resourcetype>
        <oc:size>32318359</oc:size>
        <d:getlastmodified>Tue, 20 Feb 2024 12:15:54 GMT</d:getlastmodified>
        <oc:tags/>
        <oc:favorite>0</oc:favorite>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
    <d:propstat>
      <d:prop>
        <oc:audio/>
        <oc:location/>
      </d:prop>
      <d:status>HTTP/1.1 404 Not Found</d:status>
    </d:propstat>
  </d:response>
</d:multistatus>

The old response was 5 times the same item:

<?xml version="1.0"?>
<d:multistatus xmlns:s="http://sabredav.org/ns" xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
  <d:response>
    <d:href>/dav/spaces/a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668/</d:href>
    <d:propstat>
      <d:prop>
        <oc:id>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!a0ca6a90-a365-4782-871e-d44447bbc668</oc:id>
        <oc:fileid>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!a0ca6a90-a365-4782-871e-d44447bbc668</oc:fileid>
        <oc:spaceid>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668</oc:spaceid>
        <oc:shareid/>
        <d:getetag>"3eabdd6cdd6786be98ab99dfda0bbdd3"</d:getetag>
        <oc:permissions/>
        <d:resourcetype>
          <d:collection/>
        </d:resourcetype>
        <oc:size>0</oc:size>
        <d:getlastmodified>Tue, 20 Feb 2024 12:15:54 GMT</d:getlastmodified>
        <oc:favorite>0</oc:favorite>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
    <d:propstat>
      <d:prop>
        <oc:file-parent/>
      </d:prop>
      <d:status>HTTP/1.1 404 Not Found</d:status>
    </d:propstat>
  </d:response>
  <d:response>
    <d:href>/dav/spaces/a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668/New%20folder/</d:href>
    <d:propstat>
      <d:prop>
        <oc:id>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!134c39fb-1978-42ee-bf27-c1aea656cedf:354c5a1d-bf13-4d6f-b844-7580c58576fb:67000a51-b984-413b-b109-0cd6a2055f71</oc:id>
        <oc:fileid>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!134c39fb-1978-42ee-bf27-c1aea656cedf:354c5a1d-bf13-4d6f-b844-7580c58576fb:67000a51-b984-413b-b109-0cd6a2055f71</oc:fileid>
        <oc:spaceid>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668</oc:spaceid>
        <oc:file-parent>134c39fb-1978-42ee-bf27-c1aea656cedf$354c5a1d-bf13-4d6f-b844-7580c58576fb!354c5a1d-bf13-4d6f-b844-7580c58576fb</oc:file-parent>
        <oc:shareid/>
        <oc:name>New folder</oc:name>
        <d:displayname>New folder</d:displayname>
        <d:getetag>"3eabdd6cdd6786be98ab99dfda0bbdd3"</d:getetag>
        <oc:permissions>SR</oc:permissions>
        <d:resourcetype>
          <d:collection/>
        </d:resourcetype>
        <oc:size>32318359</oc:size>
        <d:getlastmodified>Tue, 20 Feb 2024 12:15:54 GMT</d:getlastmodified>
        <oc:tags/>
        <oc:favorite>0</oc:favorite>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
    <d:propstat>
      <d:prop>
        <oc:audio/>
        <oc:location/>
      </d:prop>
      <d:status>HTTP/1.1 404 Not Found</d:status>
    </d:propstat>
  </d:response>
  <d:response>
    <d:href>/dav/spaces/a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668/New%20folder/</d:href>
    <d:propstat>
      <d:prop>
        <oc:id>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!134c39fb-1978-42ee-bf27-c1aea656cedf:354c5a1d-bf13-4d6f-b844-7580c58576fb:57ccc615-b621-4469-8325-7597ca597104</oc:id>
        <oc:fileid>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!134c39fb-1978-42ee-bf27-c1aea656cedf:354c5a1d-bf13-4d6f-b844-7580c58576fb:57ccc615-b621-4469-8325-7597ca597104</oc:fileid>
        <oc:spaceid>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668</oc:spaceid>
        <oc:file-parent>134c39fb-1978-42ee-bf27-c1aea656cedf$354c5a1d-bf13-4d6f-b844-7580c58576fb!354c5a1d-bf13-4d6f-b844-7580c58576fb</oc:file-parent>
        <oc:shareid/>
        <oc:name>New folder</oc:name>
        <d:displayname>New folder</d:displayname>
        <d:getetag>"3eabdd6cdd6786be98ab99dfda0bbdd3"</d:getetag>
        <oc:permissions>SR</oc:permissions>
        <d:resourcetype>
          <d:collection/>
        </d:resourcetype>
        <oc:size>32318359</oc:size>
        <d:getlastmodified>Tue, 20 Feb 2024 12:15:54 GMT</d:getlastmodified>
        <oc:tags/>
        <oc:favorite>0</oc:favorite>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
    <d:propstat>
      <d:prop>
        <oc:audio/>
        <oc:location/>
      </d:prop>
      <d:status>HTTP/1.1 404 Not Found</d:status>
    </d:propstat>
  </d:response>
  <d:response>
    <d:href>/dav/spaces/a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668/New%20folder/</d:href>
    <d:propstat>
      <d:prop>
        <oc:id>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!134c39fb-1978-42ee-bf27-c1aea656cedf:354c5a1d-bf13-4d6f-b844-7580c58576fb:5d86f65f-e2c5-4107-87c1-cc4de7161dc9</oc:id>
        <oc:fileid>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!134c39fb-1978-42ee-bf27-c1aea656cedf:354c5a1d-bf13-4d6f-b844-7580c58576fb:5d86f65f-e2c5-4107-87c1-cc4de7161dc9</oc:fileid>
        <oc:spaceid>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668</oc:spaceid>
        <oc:file-parent>134c39fb-1978-42ee-bf27-c1aea656cedf$354c5a1d-bf13-4d6f-b844-7580c58576fb!354c5a1d-bf13-4d6f-b844-7580c58576fb</oc:file-parent>
        <oc:shareid/>
        <oc:name>New folder</oc:name>
        <d:displayname>New folder</d:displayname>
        <d:getetag>"3eabdd6cdd6786be98ab99dfda0bbdd3"</d:getetag>
        <oc:permissions>SR</oc:permissions>
        <d:resourcetype>
          <d:collection/>
        </d:resourcetype>
        <oc:size>32318359</oc:size>
        <d:getlastmodified>Tue, 20 Feb 2024 12:15:54 GMT</d:getlastmodified>
        <oc:tags/>
        <oc:favorite>0</oc:favorite>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
    <d:propstat>
      <d:prop>
        <oc:audio/>
        <oc:location/>
      </d:prop>
      <d:status>HTTP/1.1 404 Not Found</d:status>
    </d:propstat>
  </d:response>
  <d:response>
    <d:href>/dav/spaces/a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668/New%20folder/</d:href>
    <d:propstat>
      <d:prop>
        <oc:id>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!134c39fb-1978-42ee-bf27-c1aea656cedf:354c5a1d-bf13-4d6f-b844-7580c58576fb:6a03474e-c922-4d1b-be19-ac22455f3d2c</oc:id>
        <oc:fileid>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!134c39fb-1978-42ee-bf27-c1aea656cedf:354c5a1d-bf13-4d6f-b844-7580c58576fb:6a03474e-c922-4d1b-be19-ac22455f3d2c</oc:fileid>
        <oc:spaceid>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668</oc:spaceid>
        <oc:file-parent>134c39fb-1978-42ee-bf27-c1aea656cedf$354c5a1d-bf13-4d6f-b844-7580c58576fb!354c5a1d-bf13-4d6f-b844-7580c58576fb</oc:file-parent>
        <oc:shareid/>
        <oc:name>New folder</oc:name>
        <d:displayname>New folder</d:displayname>
        <d:getetag>"3eabdd6cdd6786be98ab99dfda0bbdd3"</d:getetag>
        <oc:permissions>SR</oc:permissions>
        <d:resourcetype>
          <d:collection/>
        </d:resourcetype>
        <oc:size>32318359</oc:size>
        <d:getlastmodified>Tue, 20 Feb 2024 12:15:54 GMT</d:getlastmodified>
        <oc:tags/>
        <oc:favorite>0</oc:favorite>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
    <d:propstat>
      <d:prop>
        <oc:audio/>
        <oc:location/>
      </d:prop>
      <d:status>HTTP/1.1 404 Not Found</d:status>
    </d:propstat>
  </d:response>
  <d:response>
    <d:href>/dav/spaces/a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668/New%20folder/</d:href>
    <d:propstat>
      <d:prop>
        <oc:id>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!134c39fb-1978-42ee-bf27-c1aea656cedf:354c5a1d-bf13-4d6f-b844-7580c58576fb:55bb6cce-c22a-4af2-9704-6fa62f975a9b</oc:id>
        <oc:fileid>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!134c39fb-1978-42ee-bf27-c1aea656cedf:354c5a1d-bf13-4d6f-b844-7580c58576fb:55bb6cce-c22a-4af2-9704-6fa62f975a9b</oc:fileid>
        <oc:spaceid>a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668</oc:spaceid>
        <oc:file-parent>134c39fb-1978-42ee-bf27-c1aea656cedf$354c5a1d-bf13-4d6f-b844-7580c58576fb!354c5a1d-bf13-4d6f-b844-7580c58576fb</oc:file-parent>
        <oc:shareid/>
        <oc:name>New folder</oc:name>
        <d:displayname>New folder</d:displayname>
        <d:getetag>"3eabdd6cdd6786be98ab99dfda0bbdd3"</d:getetag>
        <oc:permissions>SR</oc:permissions>
        <d:resourcetype>
          <d:collection/>
        </d:resourcetype>
        <oc:size>32318359</oc:size>
        <d:getlastmodified>Tue, 20 Feb 2024 12:15:54 GMT</d:getlastmodified>
        <oc:tags/>
        <oc:favorite>0</oc:favorite>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
    <d:propstat>
      <d:prop>
        <oc:audio/>
        <oc:location/>
      </d:prop>
      <d:status>HTTP/1.1 404 Not Found</d:status>
    </d:propstat>
  </d:response>
</d:multistatus>

The fetchShares call is already stat'ing the resource a few lines above.
If that didn't return and info, why should it do here?
When listing the sharejail root, merge shares that target the same resource
into a single resource. In order to avoid the resourceId changing randomly the
id will be composed from the oldest accepted share that exist for the resource.

Ideally we'd compose the resourceId based on the id of the shared resource, but
that is currently not possible in a backwards compatible way. Some clients seem
to rely on the fact that the resource ids in the sharejail contain valid shareids.

Fixes: owncloud/ocis#8080
@butonic
butonic merged commit 3fb1ef6 into cs3org:edge Feb 21, 2024
@micbar micbar mentioned this pull request Feb 26, 2024
67 of 71 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants