From d4a51447d1b6858f2e8dae12cb2d38c2e2fa5e6b Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 17 Jul 2018 17:28:02 +0200 Subject: [PATCH] Fix getting ocs share permissions if a storage is not available Signed-off-by: Robin Appelman --- apps/dav/lib/Connector/Sabre/Node.php | 13 ++++++++----- apps/dav/tests/unit/Connector/Sabre/NodeTest.php | 3 ++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/dav/lib/Connector/Sabre/Node.php b/apps/dav/lib/Connector/Sabre/Node.php index 9e78d21a39..38d0ff57fb 100644 --- a/apps/dav/lib/Connector/Sabre/Node.php +++ b/apps/dav/lib/Connector/Sabre/Node.php @@ -38,6 +38,7 @@ use OC\Files\Mount\MoveableMount; use OC\Files\View; use OCA\DAV\Connector\Sabre\Exception\InvalidPath; use OCP\Files\FileInfo; +use OCP\Files\StorageNotAvailableException; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager; @@ -250,15 +251,17 @@ abstract class Node implements \Sabre\DAV\INode { } } - $storage = $this->info->getStorage(); + try { + $storage = $this->info->getStorage(); + } catch (StorageNotAvailableException $e) { + $storage = null; + } - $path = $this->info->getInternalPath(); - - if ($storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) { + if ($storage && $storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) { /** @var \OCA\Files_Sharing\SharedStorage $storage */ $permissions = (int)$storage->getShare()->getPermissions(); } else { - $permissions = $storage->getPermissions($path); + $permissions = $this->info->getPermissions(); } /* diff --git a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php index b46c731d3d..2b84d8475f 100644 --- a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php @@ -151,12 +151,13 @@ class NodeTest extends \Test\TestCase { $info = $this->getMockBuilder(FileInfo::class) ->disableOriginalConstructor() - ->setMethods(['getStorage', 'getType', 'getMountPoint']) + ->setMethods(['getStorage', 'getType', 'getMountPoint', 'getPermissions']) ->getMock(); $info->method('getStorage')->willReturn($storage); $info->method('getType')->willReturn($type); $info->method('getMountPoint')->willReturn($mountpoint); + $info->method('getPermissions')->willReturn($permissions); $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor()