From 169874957a155bc01f5e573350a16f60ab586e0c Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 4 Feb 2016 13:25:24 +0100 Subject: [PATCH] Path should be relative --- lib/private/share20/manager.php | 4 +++- tests/lib/share20/managertest.php | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/private/share20/manager.php b/lib/private/share20/manager.php index 2a350f02d6..d65fb927f9 100644 --- a/lib/private/share20/manager.php +++ b/lib/private/share20/manager.php @@ -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()), )); } diff --git a/tests/lib/share20/managertest.php b/tests/lib/share20/managertest.php index 1cdf63aa7e..131bc7fbfd 100644 --- a/tests/lib/share20/managertest.php +++ b/tests/lib/share20/managertest.php @@ -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);