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;
*/
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() {
* @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,
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;
* @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;
}
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\NotFoundException;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Config\IUserMountCache;
use OCP\IUserSession;
* @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() {
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;
*/
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());
\OCA\Files_External\MountConfig::$skipTest = true;
$this->mountCache = $this->createMock(IUserMountCache::class);
+ $this->eventDispatcher = $this->createMock(IEventDispatcher::class);
// prepare BackendService mock
$this->backendService =
$this->dbConfig,
$userSession,
$this->groupManager,
- $this->mountCache
+ $this->mountCache,
+ $this->eventDispatcher,
);
}
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);
->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() {