diff options
author | Robin Appelman <robin@icewind.nl> | 2022-03-08 14:50:25 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-08 14:50:25 +0000 |
commit | e8872f01ae850bcbf66220beba44463f68e3d673 (patch) | |
tree | 9b2b1d01992d26368ff456af0440d0a2965308a6 /apps | |
parent | 23e8ae15aaea30359a927492155de13c97b311ce (diff) | |
parent | 917c74e214094e321ff96e1aa067ae60d22e2c58 (diff) | |
download | nextcloud-server-e8872f01ae850bcbf66220beba44463f68e3d673.tar.gz nextcloud-server-e8872f01ae850bcbf66220beba44463f68e3d673.zip |
Merge pull request #31431 from nextcloud/fs-setup-manager
Unify/cleanup filesystem setup
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php | 9 | ||||
-rw-r--r-- | apps/files_external/tests/PersonalMountTest.php | 7 | ||||
-rw-r--r-- | apps/files_sharing/lib/External/Manager.php | 6 | ||||
-rw-r--r-- | apps/files_sharing/lib/Updater.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/tests/External/ManagerTest.php | 18 |
5 files changed, 27 insertions, 15 deletions
diff --git a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php index d77f65b33f5..7416cf7a3f7 100644 --- a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php @@ -34,6 +34,7 @@ use OC\Files\Storage\Temporary; use OC\Files\View; use OCA\DAV\Connector\Sabre\Directory; use OCA\DAV\Connector\Sabre\ObjectTree; +use OCP\Files\Mount\IMountManager; /** * Class ObjectTreeTest @@ -266,7 +267,7 @@ class ObjectTreeTest extends \Test\TestCase { ]; } - + public function testGetNodeForPathInvalidPath() { $this->expectException(\OCA\DAV\Connector\Sabre\Exception\InvalidPath::class); @@ -287,8 +288,7 @@ class ObjectTreeTest extends \Test\TestCase { $rootNode = $this->getMockBuilder(Directory::class) ->disableOriginalConstructor() ->getMock(); - $mountManager = $this->getMockBuilder(Manager::class) - ->getMock(); + $mountManager = $this->createMock(IMountManager::class); $tree = new \OCA\DAV\Connector\Sabre\ObjectTree(); $tree->init($rootNode, $view, $mountManager); @@ -314,8 +314,7 @@ class ObjectTreeTest extends \Test\TestCase { $rootNode = $this->getMockBuilder(Directory::class) ->disableOriginalConstructor() ->getMock(); - $mountManager = $this->getMockBuilder(Manager::class) - ->getMock(); + $mountManager = $this->createMock(IMountManager::class); $tree = new \OCA\DAV\Connector\Sabre\ObjectTree(); $tree->init($rootNode, $view, $mountManager); diff --git a/apps/files_external/tests/PersonalMountTest.php b/apps/files_external/tests/PersonalMountTest.php index b8a57657f9d..024695b0188 100644 --- a/apps/files_external/tests/PersonalMountTest.php +++ b/apps/files_external/tests/PersonalMountTest.php @@ -25,8 +25,13 @@ namespace OCA\Files_External\Tests; use OC\Files\Mount\Manager; +use OC\Files\SetupManagerFactory; use OCA\Files_External\Lib\PersonalMount; use OCA\Files_External\Lib\StorageConfig; +use OCP\Diagnostics\IEventLogger; +use OCP\EventDispatcher\IEventDispatcher; +use OCP\Files\Config\IMountProviderCollection; +use OCP\IUserManager; use Test\TestCase; class PersonalMountTest extends TestCase { @@ -47,7 +52,7 @@ class PersonalMountTest extends TestCase { $mount = new PersonalMount($storageService, $storageConfig, 10, $storage, '/foo'); - $mountManager = new Manager(); + $mountManager = new Manager($this->createMock(SetupManagerFactory::class)); $mountManager->addMount($mount); $this->assertEquals([$mount], $mountManager->findByStorageId('dummy')); diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index a48e2a63ae4..a8510321a5a 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -43,6 +43,7 @@ use OCP\EventDispatcher\IEventDispatcher; use OCP\Federation\ICloudFederationFactory; use OCP\Federation\ICloudFederationProviderManager; use OCP\Files; +use OCP\Files\NotFoundException; use OCP\Files\Storage\IStorageFactory; use OCP\Http\Client\IClientService; use OCP\IDBConnection; @@ -599,8 +600,9 @@ class Manager { } public function removeShare($mountPoint): bool { - $mountPointObj = $this->mountManager->find($mountPoint); - if ($mountPointObj === null) { + try { + $mountPointObj = $this->mountManager->find($mountPoint); + } catch (NotFoundException $e) { $this->logger->error('Mount point to remove share not found', ['mountPoint' => $mountPoint]); return false; } diff --git a/apps/files_sharing/lib/Updater.php b/apps/files_sharing/lib/Updater.php index 9ce114f495d..ad194dde016 100644 --- a/apps/files_sharing/lib/Updater.php +++ b/apps/files_sharing/lib/Updater.php @@ -26,6 +26,7 @@ */ namespace OCA\Files_Sharing; +use OC\Files\Mount\MountPoint; use OCP\Constants; use OCP\Share\IShare; @@ -105,6 +106,7 @@ class Updater { $mountManager = \OC\Files\Filesystem::getMountManager(); $mountedShares = $mountManager->findIn('/' . \OC_User::getUser() . '/files/' . $oldPath); foreach ($mountedShares as $mount) { + /** @var MountPoint $mount */ if ($mount->getStorage()->instanceOfStorage(ISharedStorage::class)) { $mountPoint = $mount->getMountPoint(); $target = str_replace($absOldPath, $absNewPath, $mountPoint); diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php index ab7c682c3a6..307b630970f 100644 --- a/apps/files_sharing/tests/External/ManagerTest.php +++ b/apps/files_sharing/tests/External/ManagerTest.php @@ -31,14 +31,19 @@ namespace OCA\Files_Sharing\Tests\External; use OC\Federation\CloudIdManager; +use OC\Files\SetupManager; +use OC\Files\SetupManagerFactory; use OC\Files\Storage\StorageFactory; use OCA\Files_Sharing\External\Manager; use OCA\Files_Sharing\External\MountProvider; use OCA\Files_Sharing\Tests\TestCase; use OCP\Contacts\IManager; +use OCP\Diagnostics\IEventLogger; use OCP\EventDispatcher\IEventDispatcher; use OCP\Federation\ICloudFederationFactory; use OCP\Federation\ICloudFederationProviderManager; +use OCP\Files\Config\IMountProviderCollection; +use OCP\Files\NotFoundException; use OCP\Http\Client\IClientService; use OCP\Http\Client\IResponse; use OCP\IGroup; @@ -102,9 +107,8 @@ class ManagerTest extends TestCase { parent::setUp(); $this->uid = $this->getUniqueID('user'); - $this->createUser($this->uid, ''); - $this->user = \OC::$server->getUserManager()->get($this->uid); - $this->mountManager = new \OC\Files\Mount\Manager(); + $this->user = $this->createUser($this->uid, ''); + $this->mountManager = new \OC\Files\Mount\Manager($this->createMock(SetupManagerFactory::class)); $this->clientService = $this->getMockBuilder(IClientService::class) ->disableOriginalConstructor()->getMock(); $this->cloudFederationProviderManager = $this->createMock(ICloudFederationProviderManager::class); @@ -740,12 +744,12 @@ class ManagerTest extends TestCase { private function assertNotMount($mountPoint) { $mountPoint = rtrim($mountPoint, '/'); - $mount = $this->mountManager->find($this->getFullPath($mountPoint)); - if ($mount) { + try { + $mount = $this->mountManager->find($this->getFullPath($mountPoint)); $this->assertInstanceOf('\OCP\Files\Mount\IMountPoint', $mount); $this->assertNotEquals($this->getFullPath($mountPoint), rtrim($mount->getMountPoint(), '/')); - } else { - $this->assertNull($mount); + } catch (NotFoundException $e) { + } } |