Path should be relative

This commit is contained in:
Roeland Jago Douma 2016-02-04 13:25:24 +01:00
parent b57aac0a89
commit 169874957a
2 changed files with 8 additions and 3 deletions

View 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()),
));
}

View 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);