Skip to content

Return tags/favorites in WebDAV calls #12856

Closed

Description

@PVince81

The first thing I'll try is returning them as part of the XML properties:

  <d:response>
    <d:href>/owncloud/remote.php/webdav/food/</d:href>
    <d:propstat>
      <d:prop>
        <oc:id>00000047oc11qbmm0afb</oc:id>
        <oc:permissions>RDNVCK</oc:permissions>
        <oc:size>13100072</oc:size>
        <oc:tags>tag1|tag2|tag3</oc:tags>
        <d:getetag>"548eed9ee598c"</d:getetag>
        <d:getlastmodified>Mon, 15 Dec 2014 14:18:06 GMT</d:getlastmodified>
        <d:resourcetype>
          <d:collection/>
        </d:resourcetype>
        <d:quota-used-bytes>13100072</d:quota-used-bytes>
        <d:quota-available-bytes>1057308672</d:quota-available-bytes>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
  </d:response>

As <oc:tags>tag1|tag2|tag3</oc:tags>, not sure if a property can have multiple values. Need to research that.

But first would be good to know if we agree on this or whether we want the sync client + mobile client to do extra OCS calls just to return the favorites tags... I think not.

Also note that the above addition will impact PROPFIND performance a bit, as we'll be fetching tags for all the files in the list, additionally to the properties and other info.

What do you think ?

@DeepDiver1975 @dragotin @guruz @icewind1991 @karlitschek

Activity

  1. self-assigned this
    on Dec 15, 2014
  2. added this to the milestone on Dec 15, 2014
  3. karlitschek commented on Dec 15, 2014

    @karlitschek
    Contributor

    looks good to me. but i don't know what our client people think. :-)

  4. PVince81 commented on Dec 15, 2014

    @PVince81
    ContributorAuthor

    For the detail: the way it will work:

    1. Get list of files (did that before)
    2. Do an additional SELECT on the oc_vcategory WHERE fileid IN (...) with the list of ids of all files. It's just a single additional select, so not sure about performance.
      If more than 1000 files, it will chunk on 1000 files. See https://github.com/owncloud/core/blob/master/lib/private/tags.php#L217
  5. PVince81 commented on Dec 15, 2014

    @PVince81
    ContributorAuthor
    1. Iterate over the returned ids to store the found tags into the properties structure here: https://github.com/owncloud/core/blob/master/lib/private/connector/sabre/directory.php#L146

    It looks like the WebDAV properties code is a bit messy, might need to be cleant up first if we don't want to duplicate that logic. There seem to be multiple code paths that retrieve the same properties (etag, etc)

  6. LukasReschke commented on Dec 15, 2014

    @LukasReschke
    Contributor

    oc:tagstag1|tag2|tag3/oc:tags

    What about using an XML array for that? - Using | as separator looks really odd.

    For example:

    <oc:tags>
      <tag>foo</tag>
      <tag>bar</tag>
    </oc:tags>
  7. PVince81 commented on Dec 15, 2014

    @PVince81
    ContributorAuthor

    I know, I need to find out whether WebDAV properties support that.

  8. PVince81 commented on Dec 15, 2014

    @PVince81
    ContributorAuthor

    I tried passing an "array" to SabreDAV and it threw an exception, so maybe not possible to use arrays.

    Furthermore I just found out that the Webdav properties API is broken: #12862

  9. dragotin commented on Dec 15, 2014

    @dragotin
    Contributor

    PROPFIND is a crucial thing. As we know, we use it a lot in the client's discovery phase, and it is a direct factor of overall performance of the clients. So we have to be very carefully here.

    However, I think the approach to return the tags (even if I only can assume what they are) with a PROPFIND result is correct, as long as this is considered:

    When a client does PROPFIND, it should send a list of attributes it expects in the result. The desktop clients do that like this for example:

        { "DAV:", "getlastmodified" },
        { "DAV:", "getcontentlength" },
        { "DAV:", "resourcetype" },
        { "DAV:", "getetag"},
        { "http://owncloud.org/ns", "id"},
        { "http://owncloud.org/ns", "dDU"},
        { "http://owncloud.org/ns", "dDC"},
        { "http://owncloud.org/ns", "permissions"},
    

    We should be fine if the server code analyzes the attribute list and avoids additional sql commands for attributes which are not required for the answer.

    If it is to complicated on a "per attribute" base, we also can identify the attributes of massivly used PROPFINDs and implement specific functions on the server to fetch the sets. That is of course a bit more fragile in case we add/remove attribs.

    About the | as separator: I'd say better do not. That opens another nice little door to hell again :hurtrealbad: . Better use the XML defined lists. However, as the tags can be a lot, I'd choose a very short XML element name (maybe t) combined with a proper namespace. Namespacing is a science anyway ;-)

  10. PVince81 commented on Dec 15, 2014

    @PVince81
    ContributorAuthor

    @dragotin thanks a lot for your input!
    When I wrote this it was before I found out that extra attrs need to be explicitly requested with PROPFIND. So then I got the same idea you just suggested: add a oc:tags attribute that only appears when explicitly requested, and also avoids extra SELECTs when not requested.
    This should be possible already (tried it locally).

    I'm still hesitating whether to provide oc:tags alone with the reserved ugly favorite tag _$!<Favorite>!$_ (it was already there, didn't invent it...) or whether to go with both oc:tags and oc:favorite, but with the ugly tag removed from oc:tags.

    As for the XML element list, I'm not sure whether WebDAV attrs support that. I didn't find how to make SabreDAV split the value into multiple sub-properties (array didn't work). Maybe there's a way, needs further research.

    Also I'd like to try out PROPPATCH for modifying the oc:tag list (and oc:favorite if we go that way), as it seems to already work for custom properties. And that would fit well with the WebDAV protocol. (at least it feels more integrated than providing a separate OCS endpoint)

    On a side note: I saw many inconsistencies in our SabreDAV code. Sometimes props are read inside the Node/File/Directory, sometimes in beforeGetProperties (sometimes both / duplicate code). Might need a good tidying up...

  11. PVince81 commented on Dec 15, 2014

    @PVince81
    ContributorAuthor

    I found how to group tags, had to implement the "DAV\Property" (inspired from HrefList / Href from SabreDAV)

    Result is here: #12865

    It looks like this:

        <d:propstat>
          <d:prop>
            <oc:id>00000066oc11qbmm0afb</oc:id>
            <oc:permissions>RDNVW</oc:permissions>
            <oc:tags>
              <oc:tag>_$!&lt;Favorite&gt;!$_</oc:tag>
              <oc:tag>tag1</oc:tag>
              <oc:tag>tag2</oc:tag>
            </oc:tags>
            <d:getcontenttype>text/plain</d:getcontenttype>
          </d:prop>
          <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    
  12. PVince81 commented on Dec 16, 2014

    @PVince81
    ContributorAuthor

    Here is an updated PROPFIND where I split oc:tags and oc:favorite:

    When the file is tagged with "tag1", "tag2" and is NOT favorited (but the property was requested)

          <d:prop>
            <oc:tags>
              <oc:tag>tag1</oc:tag>
              <oc:tag>tag2</oc:tag>
            </oc:tags>
            <oc:favorite/>
          </d:prop>
    

    Whenever a file is favorited you'll get <oc:favorite>1</oc:favorite>. Not sure whether we had booleans so far ? SabreDAV converts boolean "true" to 1 automatically.

    Both properties can be changed with PROPPATCH.

    This already works in this PR #12865
    But more work is needed for scalability.

  13. locked as resolved and limited conversation to collaborators on Aug 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions