Merge pull request #10277 from nextcloud/ocs-permissions-storage-not-available
Fix getting ocs share permissions if a storage is not available
This commit is contained in:
commit
ddebdb02fb
|
@ -38,6 +38,7 @@ use OC\Files\Mount\MoveableMount;
|
||||||
use OC\Files\View;
|
use OC\Files\View;
|
||||||
use OCA\DAV\Connector\Sabre\Exception\InvalidPath;
|
use OCA\DAV\Connector\Sabre\Exception\InvalidPath;
|
||||||
use OCP\Files\FileInfo;
|
use OCP\Files\FileInfo;
|
||||||
|
use OCP\Files\StorageNotAvailableException;
|
||||||
use OCP\Share\Exceptions\ShareNotFound;
|
use OCP\Share\Exceptions\ShareNotFound;
|
||||||
use OCP\Share\IManager;
|
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 && $storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) {
|
||||||
|
|
||||||
if ($storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) {
|
|
||||||
/** @var \OCA\Files_Sharing\SharedStorage $storage */
|
/** @var \OCA\Files_Sharing\SharedStorage $storage */
|
||||||
$permissions = (int)$storage->getShare()->getPermissions();
|
$permissions = (int)$storage->getShare()->getPermissions();
|
||||||
} else {
|
} else {
|
||||||
$permissions = $storage->getPermissions($path);
|
$permissions = $this->info->getPermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -151,12 +151,13 @@ class NodeTest extends \Test\TestCase {
|
||||||
|
|
||||||
$info = $this->getMockBuilder(FileInfo::class)
|
$info = $this->getMockBuilder(FileInfo::class)
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->setMethods(['getStorage', 'getType', 'getMountPoint'])
|
->setMethods(['getStorage', 'getType', 'getMountPoint', 'getPermissions'])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$info->method('getStorage')->willReturn($storage);
|
$info->method('getStorage')->willReturn($storage);
|
||||||
$info->method('getType')->willReturn($type);
|
$info->method('getType')->willReturn($type);
|
||||||
$info->method('getMountPoint')->willReturn($mountpoint);
|
$info->method('getMountPoint')->willReturn($mountpoint);
|
||||||
|
$info->method('getPermissions')->willReturn($permissions);
|
||||||
|
|
||||||
$view = $this->getMockBuilder(View::class)
|
$view = $this->getMockBuilder(View::class)
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
|
|
Loading…
Reference in New Issue