Skip to content

Returns tags through WebDAV - #12865

Merged
MorrisJobke merged 3 commits into
masterfrom
files-tags-webdav
Dec 19, 2014
Merged

MorrisJobke merged 3 commits into
masterfrom
files-tags-webdav

Conversation

@PVince81

Copy link
Copy Markdown
Contributor

Fixes #12856

I figured out how to make it return a list of tags 😄

@DeepDiver1975 @dragotin @icewind1991

  • only select/return tags when explicitly requested
  • separate tags from favorite ?
  • unit tests

@PVince81

Copy link
Copy Markdown
Contributor Author
  • seems the Tag class might not even be needed

@PVince81

Copy link
Copy Markdown
Contributor Author
  • find out whether this can be done as a separate plugin instead

@PVince81

Copy link
Copy Markdown
Contributor Author

I've added PROPPATCH for oc:tags: the list is the absolute list of tags, which means it will replace the tags with the given ones, including the favorite one. It already works but the response of PROPPATCH isn't correct yet.

  • fix PROPPATCH response to return the applied tags (if needed by the spec) instead of an empty oc:tags structure

The code is still quite unclean, I just wanted a POC that it can work 😄

@PVince81

Copy link
Copy Markdown
Contributor Author
  • prevent getChildren() to run its loops twice, cache nodes

@PVince81

Copy link
Copy Markdown
Contributor Author

Just did a test with 1000 files where I randomly favorited a few.
The speed reported by curl for PROPFIND on that dir is roughly:

  • 900K without requesting tags/fav
  • 375K when requesting tags/fav
    This means that requesting tags + favorites will be around 40% slower.

Note that it doesn't make much difference to request the one or the other separately. Favorite is a kind of tag so that information needs to be read anyway. We currently use a query that selects all tags for a list of file ids.

One possible improvement would be to write a special query to request only the favorites for a list of file ids instead of all tags, but only if favorites are requested ALONE without requesting tags.
Since that would need adding additional public APIs in that ITags implementation I'd rather leave it for now. I guess there is still time to improve the performance until the sync clients are ready to deal with tags/favorite.

@PVince81

Copy link
Copy Markdown
Contributor Author

@icewind1991 @DeepDiver1975 can you guys review the code ?

My next step now is to implement the unit tests.

@PVince81 PVince81 mentioned this pull request Dec 17, 2014
@PVince81 PVince81 changed the title [WIP] Returns tags through WebDAV Returns tags through WebDAV Dec 17, 2014
@PVince81 PVince81 added this to the 8.0-current milestone Dec 17, 2014
@PVince81 PVince81 self-assigned this Dec 17, 2014
Added oc:tags and oc:favorites in PROPFIND response.
It is possible to update them with PROPPATCH.
These properties are optional which means they need to be requested
explicitly
@PVince81

Copy link
Copy Markdown
Contributor Author

I've added unit tests for the new TagsPlugin and squashed everything.

Please review @DeepDiver1975 @icewind1991

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this checks if the client requests the tags to be returned?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. SabreDAV passes the queries properties in "requestedProperties".
Once we find it we remove it to avoid reading it from the oc_properties table later on.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Goal is to avoid retrieving tags/favs if they weren't explicitly requested. (for performance, etc)

@PVince81

Copy link
Copy Markdown
Contributor Author

This is what I used to test:

  1. create a file "testprops.txt" in the web UI
  2. create a local "propfind.txt" file (for curl)
<?xml version="1.0"?>
<a:propfind xmlns:a="DAV:" xmlns:oc="http://owncloud.org/ns">
<a:prop><a:getcontenttype/></a:prop>
<a:prop><oc:testprop/></a:prop>
<a:prop><oc:tags/></a:prop>
<a:prop><oc:favorite/></a:prop>
</a:propfind>
  1. Create a local file proppatch.txt (for curl):
<?xml version="1.0"?>
<d:propertyupdate xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
  <d:set>
    <d:prop>
                <oc:tags>
                        <oc:tag>tag1</oc:tag>
                        <oc:tag>tag2</oc:tag>
                </oc:tags>
                <oc:favorite>1</oc:favorite>
    </d:prop>
  </d:set>
</d:propertyupdate>
  1. Run curl to set tags/favorites:
    curl -X PROPPATCH -H "Content-Type: text/xml" --data-binary "@proppatch.txt" http://root:admin@localhost/owncloud/remote.php/webdav/testprops.txt | xmllint --format -
    The response must contain the updated tags/favs.
  2. Run PROPFIND to get tags/favorites on the file directlry:
    curl -X PROPFIND -H "Content-Type: text/xml" --data-binary "@propfind.txt" http://root:admin@localhost/owncloud/remote.php/webdav/testprops.txt | xmllint --format -
    You should see tags/favs on testprops.txt.
  3. Run PROPFIND on the root to see the tags/favs on the individual files:
    curl -X PROPFIND -H "Content-Type: text/xml" --data-binary "@propfind.txt" http://root:admin@localhost/owncloud/remote.php/webdav/ | xmllint --format -
    You should see tags/favs on testprops.txt.
  4. Run PROPFIND without requesting tag/fav:
    curl -X PROPFIND http://root:admin@localhost/owncloud/remote.php/webdav/ | xmllint --format -
    Here you should see that tags/favs are not returned
  5. Change "proppatch.txt" with different values and try again.

@PVince81

Copy link
Copy Markdown
Contributor Author
  1. also check that the file was favved/unfavved in the web GUI when setting/unsetting oc:favorite

@icewind1991

Copy link
Copy Markdown
Contributor

Multiple tags don't seem to be properly returned

<oc:tags>tag1tag4</oc:tags>

@icewind1991

Copy link
Copy Markdown
Contributor

setting <oc:favorite>1</oc:favorite> doesn't seem to effect the favorite status in the web ui and vice-versa.

Also the xml returned from propfind has 2 propstat entries

<?xml version="1.0" encoding="utf-8"?>
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns">
  <d:response>
    <d:href>/owncloud/remote.php/webdav/tiny.jpg</d:href>
    <d:propstat>
      <d:prop>
        <oc:id>00002598ocg7ou11dvla</oc:id>
        <oc:permissions>RDNVW</oc:permissions>
        <oc:tags>tag1tag4</oc:tags>
        <oc:favorite>1</oc:favorite>
        <d:getcontenttype>image/jpeg</d:getcontenttype>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
    <d:propstat>
      <d:prop>
        <oc:testprop/>
      </d:prop>
      <d:status>HTTP/1.1 404 Not Found</d:status>
    </d:propstat>
  </d:response>
</d:multistatus>

@PVince81

Copy link
Copy Markdown
Contributor Author

Strange. It works for me locally:
After PROPPATCH with the above file:

<?xml version="1.0" encoding="utf-8"?>
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns">
  <d:response>
    <d:href>/owncloud/remote.php/webdav/testprops.txt</d:href>
    <d:propstat>
      <d:prop>
        <oc:tags>
          <oc:tag>tag1</oc:tag>
          <oc:tag>tag2</oc:tag>
        </oc:tags>
        <oc:favorite>1</oc:favorite>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
  </d:response>
</d:multistatus>

then PROPFIND on testprops.txt:

<?xml version="1.0" encoding="utf-8"?>
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns">
  <d:response>
    <d:href>/owncloud/remote.php/webdav/testprops.txt</d:href>
    <d:propstat>
      <d:prop>
        <oc:id>00000003oc11qbmm0afb</oc:id>
        <oc:permissions>RDNVW</oc:permissions>
        <oc:tags>
          <oc:tag>tag1</oc:tag>
          <oc:tag>tag2</oc:tag>
        </oc:tags>
        <oc:favorite>1</oc:favorite>
        <d:getcontenttype>text/plain</d:getcontenttype>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
    <d:propstat>
      <d:prop>
        <oc:testprop/>
      </d:prop>
      <d:status>HTTP/1.1 404 Not Found</d:status>
    </d:propstat>
  </d:response>
</d:multistatus>

@icewind1991

Copy link
Copy Markdown
Contributor

Never mind, failed to properly checkout the branch....

@icewind1991

Copy link
Copy Markdown
Contributor

works, code looks good 👍

@PVince81

Copy link
Copy Markdown
Contributor Author

As recommended by @LukasReschke I tried running xhprof.
I used a folder with 1000 files with about 30 of them favorited across the list.
The longest run is the one that includes tags and favorites, the other one is without:
xhprof_webdav_tags

So it takes about 2.35 times longer to run.

@PVince81

Copy link
Copy Markdown
Contributor Author

Jenkins test run here: #12937

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no return in here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh noes, that's an old method that should be gone. Will remove.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\OCP\FileInfo is unknown - missing I ???

@PVince81

Copy link
Copy Markdown
Contributor Author

@DeepDiver1975 all comments addressed, please have a look.

@scrutinizer-notifier

Copy link
Copy Markdown

The inspection completed: 15 new issues, 16 updated code elements

@MorrisJobke

Copy link
Copy Markdown
Contributor

@owncloud-bot retest this please

@DeepDiver1975

Copy link
Copy Markdown
Contributor

👍

@MorrisJobke

Copy link
Copy Markdown
Contributor

👍 tested and works :)

@MorrisJobke

Copy link
Copy Markdown
Contributor

@owncloud-bot retest this please

@MorrisJobke

Copy link
Copy Markdown
Contributor

backup jenkins PR: #12951

@ghost

ghost commented Dec 19, 2014

Copy link
Copy Markdown

Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/5096/

Build result: FAILURE

[...truncated 17 lines...]using GIT_SSH to set credentials using .gitcredentials to set credentials > git config --local credential.helper store --file=/tmp/git766125148017817045.credentials # timeout=10 > git fetch --tags --progress https://github.com/owncloud/core.git +refs/pull/:refs/remotes/origin/pr/ > git config --local --remove-section credential # timeout=10 > git rev-parse origin/pr/12865/merge^{commit} # timeout=10 > git branch -a --contains abfe3f59bb2ef68cfbb6f268d53c34fa0fa713e7 # timeout=10 > git rev-parse remotes/origin/pr/12865/merge^{commit} # timeout=10Checking out Revision abfe3f59bb2ef68cfbb6f268d53c34fa0fa713e7 (origin/pr/12865/merge) > git config core.sparsecheckout # timeout=10 > git checkout -f abfe3f59bb2ef68cfbb6f268d53c34fa0fa713e7 > git rev-list 65b5ab94b254da31e4a905e86e47ed51be74d61f # timeout=10First time build. Skipping changelog. > git remote # timeout=10 > git submodule init # timeout=10 > git submodule sync # timeout=10 > git config --get remote.origin.url # timeout=10 > git submodule update --init --recursiveTriggering pull-request-analyser-ng-simple » SLAVEpull-request-analyser-ng-simple » SLAVE completed with result FAILUREStarted calculate disk usage of buildFinished Calculation of disk usage of build in 0 secondsStarted calculate disk usage of workspaceFinished Calculation of disk usage of workspace in 1 second
Test FAILed.

@MorrisJobke

Copy link
Copy Markdown
Contributor

@owncloud-bot retest this please

@MorrisJobke

Copy link
Copy Markdown
Contributor

Tests passed: #12951 (comment)

MorrisJobke added a commit that referenced this pull request Dec 19, 2014
@MorrisJobke
MorrisJobke merged commit 39d6ddd into master Dec 19, 2014
@MorrisJobke
MorrisJobke deleted the files-tags-webdav branch December 19, 2014 08:33
@ghost

ghost commented Dec 19, 2014

Copy link
Copy Markdown

Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/5109/
Test FAILed.

@lock lock Bot locked as resolved and limited conversation to collaborators Aug 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Return tags/favorites in WebDAV calls

6 participants