mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
force full setup after external storage config change
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
15c9a3114a
commit
fc6e4530c4
6 changed files with 34 additions and 8 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -100,7 +100,8 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
|
|||
$this->dbConfig,
|
||||
$userSession,
|
||||
$this->groupManager,
|
||||
$this->mountCache
|
||||
$this->mountCache,
|
||||
$this->eventDispatcher,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue