]> source.dussan.org Git - nextcloud-server.git/commitdiff
force full setup after external storage config change
authorRobin Appelman <robin@icewind.nl>
Thu, 17 Mar 2022 17:24:18 +0000 (18:24 +0100)
committerRobin Appelman <robin@icewind.nl>
Thu, 24 Mar 2022 16:03:44 +0000 (17:03 +0100)
Signed-off-by: Robin Appelman <robin@icewind.nl>
apps/files_external/lib/Service/StoragesService.php
apps/files_external/lib/Service/UserGlobalStoragesService.php
apps/files_external/lib/Service/UserStoragesService.php
apps/files_external/tests/Service/StoragesServiceTest.php
apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
apps/files_external/tests/Service/UserStoragesServiceTest.php

index b8eabd65e1ec157cbc93c25f3cf480f0275b2292..6d03590d345e8263c5fc91e6b2008aca988bf58b 100644 (file)
@@ -40,7 +40,9 @@ use OCA\Files_External\Lib\Backend\InvalidBackend;
 use OCA\Files_External\Lib\DefinitionParameter;
 use OCA\Files_External\Lib\StorageConfig;
 use OCA\Files_External\NotFoundException;
+use OCP\EventDispatcher\IEventDispatcher;
 use OCP\Files\Config\IUserMountCache;
+use OCP\Files\Events\InvalidateMountCacheEvent;
 use OCP\Files\StorageNotAvailableException;
 use OCP\ILogger;
 
@@ -62,15 +64,24 @@ abstract class StoragesService {
         */
        protected $userMountCache;
 
+       protected IEventDispatcher $eventDispatcher;
+
        /**
         * @param BackendService $backendService
         * @param DBConfigService $dbConfigService
         * @param IUserMountCache $userMountCache
+        * @param IEventDispatcher $eventDispatcher
         */
-       public function __construct(BackendService $backendService, DBConfigService $dbConfigService, IUserMountCache $userMountCache) {
+       public function __construct(
+               BackendService $backendService,
+               DBConfigService $dbConfigService,
+               IUserMountCache $userMountCache,
+               IEventDispatcher $eventDispatcher
+       ) {
                $this->backendService = $backendService;
                $this->dbConfig = $dbConfigService;
                $this->userMountCache = $userMountCache;
+               $this->eventDispatcher = $eventDispatcher;
        }
 
        protected function readDBConfig() {
@@ -339,6 +350,7 @@ abstract class StoragesService {
         * @param array $applicableArray array of applicable users/groups for which to trigger the hook
         */
        protected function triggerApplicableHooks($signal, $mountPoint, $mountType, $applicableArray) {
+               $this->eventDispatcher->dispatchTyped(new InvalidateMountCacheEvent(null));
                foreach ($applicableArray as $applicable) {
                        \OCP\Util::emitHook(
                                Filesystem::CLASSNAME,
index ba894d8f2106e072c42009433e4513e46dd1d89f..2eda36e92429d0fa815d9703c317263068f87995 100644 (file)
@@ -24,6 +24,7 @@
 namespace OCA\Files_External\Service;
 
 use OCA\Files_External\Lib\StorageConfig;
+use OCP\EventDispatcher\IEventDispatcher;
 use OCP\Files\Config\IUserMountCache;
 use OCP\IGroupManager;
 use OCP\IUser;
@@ -45,15 +46,17 @@ class UserGlobalStoragesService extends GlobalStoragesService {
         * @param IUserSession $userSession
         * @param IGroupManager $groupManager
         * @param IUserMountCache $userMountCache
+        * @param IEventDispatcher $eventDispatcher
         */
        public function __construct(
                BackendService $backendService,
                DBConfigService $dbConfig,
                IUserSession $userSession,
                IGroupManager $groupManager,
-               IUserMountCache $userMountCache
+               IUserMountCache $userMountCache,
+               IEventDispatcher $eventDispatcher
        ) {
-               parent::__construct($backendService, $dbConfig, $userMountCache);
+               parent::__construct($backendService, $dbConfig, $userMountCache, $eventDispatcher);
                $this->userSession = $userSession;
                $this->groupManager = $groupManager;
        }
index 8af6bdb3a7773fa64537033550781170ae548722..b09b37b40ccf7bc637fb31a22f25f1cbb7d685da 100644 (file)
@@ -32,6 +32,7 @@ use OC\Files\Filesystem;
 use OCA\Files_External\Lib\StorageConfig;
 use OCA\Files_External\NotFoundException;
 
+use OCP\EventDispatcher\IEventDispatcher;
 use OCP\Files\Config\IUserMountCache;
 use OCP\IUserSession;
 
@@ -49,15 +50,17 @@ class UserStoragesService extends StoragesService {
         * @param DBConfigService $dbConfig
         * @param IUserSession $userSession user session
         * @param IUserMountCache $userMountCache
+        * @param IEventDispatcher $eventDispatcher
         */
        public function __construct(
                BackendService $backendService,
                DBConfigService $dbConfig,
                IUserSession $userSession,
-               IUserMountCache $userMountCache
+               IUserMountCache $userMountCache,
+               IEventDispatcher $eventDispatcher
        ) {
                $this->userSession = $userSession;
-               parent::__construct($backendService, $dbConfig, $userMountCache);
+               parent::__construct($backendService, $dbConfig, $userMountCache, $eventDispatcher);
        }
 
        protected function readDBConfig() {
index 3829a9ea0cea809cab245e93a26d4007c39da074..4eaf70a8e84a09e69c62c89a0b5c29a29ff56056 100644 (file)
@@ -39,6 +39,7 @@ use OCA\Files_External\Service\BackendService;
 use OCA\Files_External\Service\DBConfigService;
 use OCA\Files_External\Service\StoragesService;
 use OCP\AppFramework\IAppContainer;
+use OCP\EventDispatcher\IEventDispatcher;
 use OCP\Files\Cache\ICache;
 use OCP\Files\Config\IUserMountCache;
 use OCP\Files\Mount\IMountPoint;
@@ -96,6 +97,11 @@ abstract class StoragesServiceTest extends \Test\TestCase {
         */
        protected $mountCache;
 
+       /**
+        * @var \PHPUnit\Framework\MockObject\MockObject|IEventDispatcher
+        */
+       protected IEventDispatcher $eventDispatcher;
+
        protected function setUp(): void {
                parent::setUp();
                $this->dbConfig = new CleaningDBConfig(\OC::$server->getDatabaseConnection(), \OC::$server->getCrypto());
@@ -108,6 +114,7 @@ abstract class StoragesServiceTest extends \Test\TestCase {
                \OCA\Files_External\MountConfig::$skipTest = true;
 
                $this->mountCache = $this->createMock(IUserMountCache::class);
+               $this->eventDispatcher = $this->createMock(IEventDispatcher::class);
 
                // prepare BackendService mock
                $this->backendService =
index ea77148c8f219d70a9cb794f26ec066f40726525..aa5aa1df431e0b758cfa02a20000b995d6a190c7 100644 (file)
@@ -100,7 +100,8 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
                        $this->dbConfig,
                        $userSession,
                        $this->groupManager,
-                       $this->mountCache
+                       $this->mountCache,
+                       $this->eventDispatcher,
                );
        }
 
index ff39ea9ddbca7505aab3cb151cc22bed7b650b00..cda1dd0a27f160f43df7cbe3b0a6465ac49aa253 100644 (file)
@@ -54,7 +54,7 @@ class UserStoragesServiceTest extends StoragesServiceTest {
        protected function setUp(): void {
                parent::setUp();
 
-               $this->globalStoragesService = new GlobalStoragesService($this->backendService, $this->dbConfig, $this->mountCache);
+               $this->globalStoragesService = new GlobalStoragesService($this->backendService, $this->dbConfig, $this->mountCache, $this->eventDispatcher);
 
                $this->userId = $this->getUniqueID('user_');
                $this->createUser($this->userId, $this->userId);
@@ -67,7 +67,7 @@ class UserStoragesServiceTest extends StoragesServiceTest {
                        ->method('getUser')
                        ->willReturn($this->user);
 
-               $this->service = new UserStoragesService($this->backendService, $this->dbConfig, $userSession, $this->mountCache);
+               $this->service = new UserStoragesService($this->backendService, $this->dbConfig, $userSession, $this->mountCache, $this->eventDispatcher);
        }
 
        private function makeTestStorageData() {