]> source.dussan.org Git - nextcloud-server.git/commitdiff
Path should be relative
authorRoeland Jago Douma <rullzer@owncloud.com>
Thu, 4 Feb 2016 12:25:24 +0000 (13:25 +0100)
committerRoeland Jago Douma <rullzer@owncloud.com>
Thu, 4 Feb 2016 18:19:10 +0000 (19:19 +0100)
lib/private/share20/manager.php
tests/lib/share20/managertest.php

index 2a350f02d6a2f1408ab65042e15218f0fea41bd0..d65fb927f9bd9aafcb1c5abf0efb1758ee228488 100644 (file)
@@ -77,6 +77,7 @@ class Manager implements IManager {
         * @param IL10N $l
         * @param IProviderFactory $factory
         * @param IUserManager $userManager
+        * @param IRootFolder $rootFolder
         */
        public function __construct(
                        ILogger $logger,
@@ -614,6 +615,7 @@ class Manager implements IManager {
                }
 
                if ($share->getPermissions() !== $originalShare->getPermissions()) {
+                       $userFolder = $this->rootFolder->getUserFolder($share->getShareOwner());
                        \OC_Hook::emit('OCP\Share', 'post_update_permissions', array(
                                'itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder',
                                'itemSource' => $share->getNode()->getId(),
@@ -621,7 +623,7 @@ class Manager implements IManager {
                                'shareWith' => $share->getSharedWith(),
                                'uidOwner' => $share->getSharedBy(),
                                'permissions' => $share->getPermissions(),
-                               'path' => $share->getNode()->getPath(),
+                               'path' => $userFolder->getRelativePath($share->getNode()->getPath()),
                        ));
                }
 
index 1cdf63aa7e5d336077784687cec0c67f1ca90ebf..131bc7fbfd2e666cc34611d4c48cfd8cd2a86156 100644 (file)
@@ -1875,7 +1875,7 @@ class ManagerTest extends \Test\TestCase {
 
                $node = $this->getMock('\OCP\Files\File');
                $node->method('getId')->willReturn(100);
-               $node->method('getPath')->willReturn('myPath');
+               $node->method('getPath')->willReturn('/newUser/files/myPath');
 
                $manager->expects($this->once())->method('canShare')->willReturn(true);
                $manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare);
@@ -1899,6 +1899,9 @@ class ManagerTest extends \Test\TestCase {
                \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post');
                $hookListner->expects($this->never())->method('post');
 
+               $this->rootFolder->method('getUserFolder')->with('newUser')->will($this->returnSelf());
+               $this->rootFolder->method('getRelativePath')->with('/newUser/files/myPath')->willReturn('/myPath');
+
                $hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
                \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner2, 'post');
                $hookListner2->expects($this->once())->method('post')->with([
@@ -1908,7 +1911,7 @@ class ManagerTest extends \Test\TestCase {
                        'shareWith' => 'origUser',
                        'uidOwner' => 'sharer',
                        'permissions' => 31,
-                       'path' => 'myPath',
+                       'path' => '/myPath',
                ]);
 
                $manager->updateShare($share);