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

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

Merged
merged 3 commits into from Feb 21, 2024

Conversation

rhafer
Copy link
Contributor

@rhafer rhafer commented Feb 15, 2024

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
Copy link
Contributor Author

rhafer commented Feb 20, 2024

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
9 checks passed
@micbar micbar mentioned this pull request Feb 26, 2024
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.

None yet

2 participants