mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
fix: check instance of storage using helper function
instanceof cannot be used to check the instance of a storage, doing so breaks the check in certain cases. In this case, enabling the `files_accesscontrol` app breaks the check. Signed-off-by: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com>
This commit is contained in:
parent
38f8423cd6
commit
4ac0fcf02e
2 changed files with 6 additions and 1 deletions
|
|
@ -181,7 +181,7 @@ class Directory extends Node implements \Sabre\DAV\ICollection, \Sabre\DAV\IQuot
|
|||
// If we are, then only PUT and MKCOL are allowed (see plugin)
|
||||
// so we are safe to return the directory without a risk of
|
||||
// leaking files and folders structure.
|
||||
if ($storage instanceof PublicShareWrapper) {
|
||||
if ($storage->instanceOfStorage(PublicShareWrapper::class)) {
|
||||
$share = $storage->getShare();
|
||||
$allowDirectory = ($share->getPermissions() & Constants::PERMISSION_READ) !== Constants::PERMISSION_READ;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ use OCP\Constants;
|
|||
use OCP\Files\ForbiddenException;
|
||||
use OCP\Files\InvalidPathException;
|
||||
use OCP\Files\Mount\IMountPoint;
|
||||
use OCP\Files\Storage\IStorage;
|
||||
use OCP\Files\StorageNotAvailableException;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Test\Traits\UserTrait;
|
||||
|
|
@ -61,12 +62,16 @@ class DirectoryTest extends \Test\TestCase {
|
|||
|
||||
private View&MockObject $view;
|
||||
private FileInfo&MockObject $info;
|
||||
private IStorage&MockObject $storage;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->view = $this->createMock(View::class);
|
||||
$this->info = $this->createMock(FileInfo::class);
|
||||
$this->storage = $this->createMock(IStorage::class);
|
||||
$this->info->method('getStorage')
|
||||
->willReturn($this->storage);
|
||||
$this->info->method('isReadable')
|
||||
->willReturn(true);
|
||||
$this->info->method('getType')
|
||||
|
|
|
|||
Loading…
Reference in a new issue