diff --git a/apps/files_trashbin/composer/composer/autoload_classmap.php b/apps/files_trashbin/composer/composer/autoload_classmap.php index 760044d4f87cb..ef9e760741e33 100644 --- a/apps/files_trashbin/composer/composer/autoload_classmap.php +++ b/apps/files_trashbin/composer/composer/autoload_classmap.php @@ -20,7 +20,7 @@ 'OCA\\Files_Trashbin\\Exceptions\\CopyRecursiveException' => $baseDir . '/../lib/Exceptions/CopyRecursiveException.php', 'OCA\\Files_Trashbin\\Expiration' => $baseDir . '/../lib/Expiration.php', 'OCA\\Files_Trashbin\\Helper' => $baseDir . '/../lib/Helper.php', - 'OCA\\Files_Trashbin\\Hooks' => $baseDir . '/../lib/Hooks.php', + 'OCA\\Files_Trashbin\\Listener\\EventListener' => $baseDir . '/../lib/Listener/EventListener.php', 'OCA\\Files_Trashbin\\Migration\\Version1010Date20200630192639' => $baseDir . '/../lib/Migration/Version1010Date20200630192639.php', 'OCA\\Files_Trashbin\\Sabre\\AbstractTrash' => $baseDir . '/../lib/Sabre/AbstractTrash.php', 'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFile' => $baseDir . '/../lib/Sabre/AbstractTrashFile.php', diff --git a/apps/files_trashbin/composer/composer/autoload_static.php b/apps/files_trashbin/composer/composer/autoload_static.php index ef52ac0e1e76d..2c27b5ce2a8b7 100644 --- a/apps/files_trashbin/composer/composer/autoload_static.php +++ b/apps/files_trashbin/composer/composer/autoload_static.php @@ -35,7 +35,7 @@ class ComposerStaticInitFiles_Trashbin 'OCA\\Files_Trashbin\\Exceptions\\CopyRecursiveException' => __DIR__ . '/..' . '/../lib/Exceptions/CopyRecursiveException.php', 'OCA\\Files_Trashbin\\Expiration' => __DIR__ . '/..' . '/../lib/Expiration.php', 'OCA\\Files_Trashbin\\Helper' => __DIR__ . '/..' . '/../lib/Helper.php', - 'OCA\\Files_Trashbin\\Hooks' => __DIR__ . '/..' . '/../lib/Hooks.php', + 'OCA\\Files_Trashbin\\Listener\\EventListener' => __DIR__ . '/..' . '/../lib/Listener/EventListener.php', 'OCA\\Files_Trashbin\\Migration\\Version1010Date20200630192639' => __DIR__ . '/..' . '/../lib/Migration/Version1010Date20200630192639.php', 'OCA\\Files_Trashbin\\Sabre\\AbstractTrash' => __DIR__ . '/..' . '/../lib/Sabre/AbstractTrash.php', 'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFile' => __DIR__ . '/..' . '/../lib/Sabre/AbstractTrashFile.php', diff --git a/apps/files_trashbin/lib/AppInfo/Application.php b/apps/files_trashbin/lib/AppInfo/Application.php index 41466a865ac7f..01c4db494d878 100644 --- a/apps/files_trashbin/lib/AppInfo/Application.php +++ b/apps/files_trashbin/lib/AppInfo/Application.php @@ -28,16 +28,23 @@ use OCA\DAV\Connector\Sabre\Principal; use OCA\Files_Trashbin\Capabilities; use OCA\Files_Trashbin\Expiration; +use OCA\Files_Trashbin\Listener\EventListener; +use OCA\Files_Trashbin\Storage; use OCA\Files_Trashbin\Trash\ITrashManager; use OCA\Files_Trashbin\Trash\TrashManager; +use OCA\Files_Trashbin\Trashbin; use OCA\Files_Trashbin\UserMigration\TrashbinMigrator; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\App\IAppManager; +use OCP\Files\Events\BeforeFileSystemSetupEvent; +use OCP\Files\Events\Node\BeforeNodeDeletedEvent; +use OCP\Files\Events\Node\NodeWrittenEvent; use OCP\ILogger; use OCP\IServerContainer; +use OCP\User\Events\BeforeUserDeletedEvent; class Application extends App implements IBootstrap { public const APP_ID = 'files_trashbin'; @@ -55,20 +62,18 @@ public function register(IRegistrationContext $context): void { $context->registerServiceAlias('principalBackend', Principal::class); $context->registerUserMigrator(TrashbinMigrator::class); + + $context->registerEventListener(NodeWrittenEvent::class, EventListener::class); + $context->registerEventListener(BeforeUserDeletedEvent::class, EventListener::class); + + // pre and post-rename, disable trash logic for the copy+unlink case + $context->registerEventListener(BeforeNodeDeletedEvent::class, Trashbin::class); + $context->registerEventListener(BeforeFileSystemSetupEvent::class, EventListener::class); } public function boot(IBootContext $context): void { $context->injectFn([$this, 'registerTrashBackends']); - // create storage wrapper on setup - \OCP\Util::connectHook('OC_Filesystem', 'preSetup', 'OCA\Files_Trashbin\Storage', 'setupStorage'); - //Listen to delete user signal - \OCP\Util::connectHook('OC_User', 'pre_deleteUser', 'OCA\Files_Trashbin\Hooks', 'deleteUser_hook'); - //Listen to post write hook - \OCP\Util::connectHook('OC_Filesystem', 'post_write', 'OCA\Files_Trashbin\Hooks', 'post_write_hook'); - // pre and post-rename, disable trash logic for the copy+unlink case - \OCP\Util::connectHook('OC_Filesystem', 'delete', 'OCA\Files_Trashbin\Trashbin', 'ensureFileScannedHook'); - \OCA\Files\App::getNavigationManager()->add(function () { $l = \OC::$server->getL10N(self::APP_ID); return [ diff --git a/apps/files_trashbin/lib/Hooks.php b/apps/files_trashbin/lib/Hooks.php deleted file mode 100644 index 4f4cf8bb7055d..0000000000000 --- a/apps/files_trashbin/lib/Hooks.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @author Christoph Wurst - * @author Morris Jobke - * @author Robin McCorkell - * @author Vincent Petry - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * - */ -namespace OCA\Files_Trashbin; - -class Hooks { - - /** - * clean up user specific settings if user gets deleted - * @param array $params array with uid - * - * This function is connected to the pre_deleteUser signal of OC_Users - * to remove the used space for the trash bin stored in the database - */ - public static function deleteUser_hook($params) { - $uid = $params['uid']; - Trashbin::deleteUser($uid); - } - - public static function post_write_hook($params) { - $user = \OC_User::getUser(); - if (!empty($user)) { - Trashbin::resizeTrash($user); - } - } -} diff --git a/apps/files_trashbin/lib/Listener/EventListener.php b/apps/files_trashbin/lib/Listener/EventListener.php new file mode 100644 index 0000000000000..64f1f4dbadc39 --- /dev/null +++ b/apps/files_trashbin/lib/Listener/EventListener.php @@ -0,0 +1,59 @@ + + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_Trashbin\Listener; + +use OCA\Files_Trashbin\Storage; +use OCA\Files_Trashbin\Trashbin; +use OCP\EventDispatcher\Event; +use OCP\EventDispatcher\IEventListener; +use OCP\Files\Events\BeforeFileSystemSetupEvent; +use OCP\Files\Events\Node\NodeWrittenEvent; +use OCP\User\Events\BeforeUserDeletedEvent; + +class EventListener implements IEventListener { + private ?string $userId; + + public function __construct(?string $userId = null) { + $this->userId = $userId; + } + + public function handle(Event $event): void { + if ($event instanceof NodeWrittenEvent) { + // Resize trash + if (!empty($this->userId)) { + Trashbin::resizeTrash($this->userId); + } + } + + // Clean up user specific settings if user gets deleted + if ($event instanceof BeforeUserDeletedEvent) { + Trashbin::deleteUser($event->getUser()->getUID()); + } + + if ($event instanceof BeforeFileSystemSetupEvent) { + Storage::setupStorage(); + } + } +} diff --git a/apps/files_trashbin/lib/Storage.php b/apps/files_trashbin/lib/Storage.php index f08d8d25a55a9..649b60b752909 100644 --- a/apps/files_trashbin/lib/Storage.php +++ b/apps/files_trashbin/lib/Storage.php @@ -37,48 +37,31 @@ use OCP\Files\Mount\IMountPoint; use OCP\Files\Node; use OCP\Files\Storage\IStorage; -use OCP\ILogger; use OCP\IUserManager; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; class Storage extends Wrapper { - /** @var IMountPoint */ + /** @var string */ private $mountPoint; - - /** @var IUserManager */ - private $userManager; - - /** @var ILogger */ - private $logger; - - /** @var EventDispatcherInterface */ - private $eventDispatcher; - - /** @var IRootFolder */ - private $rootFolder; - - /** @var ITrashManager */ - private $trashManager; - - private $trashEnabled = true; + private ?IUserManager $userManager; + private ?LoggerInterface $logger; + private ?EventDispatcherInterface $eventDispatcher; + private ?IRootFolder $rootFolder; + private ?ITrashManager $trashManager; + private bool $trashEnabled = true; /** * Storage constructor. - * * @param array $parameters - * @param ITrashManager $trashManager - * @param IUserManager|null $userManager - * @param ILogger|null $logger - * @param EventDispatcherInterface|null $eventDispatcher - * @param IRootFolder|null $rootFolder */ public function __construct( $parameters, - ITrashManager $trashManager = null, - IUserManager $userManager = null, - ILogger $logger = null, - EventDispatcherInterface $eventDispatcher = null, - IRootFolder $rootFolder = null + ?ITrashManager $trashManager = null, + ?IUserManager $userManager = null, + ?LoggerInterface $logger = null, + ?EventDispatcherInterface $eventDispatcher = null, + ?IRootFolder $rootFolder = null ) { $this->mountPoint = $parameters['mountPoint']; $this->trashManager = $trashManager; @@ -216,7 +199,7 @@ public static function setupStorage() { ['storage' => $storage, 'mountPoint' => $mountPoint], \OC::$server->query(ITrashManager::class), \OC::$server->getUserManager(), - \OC::$server->getLogger(), + \OC::$server->get(LoggerInterface::class), \OC::$server->getEventDispatcher(), \OC::$server->getLazyRootFolder() ); diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index 4631f9e9d5bfe..ff89f724d52f8 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -44,6 +44,7 @@ */ namespace OCA\Files_Trashbin; +use OC\Files\Node\Node; use OC_User; use OC\Files\Cache\Cache; use OC\Files\Cache\CacheEntry; @@ -54,6 +55,9 @@ use OCA\Files_Trashbin\AppInfo\Application; use OCA\Files_Trashbin\Command\Expire; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\EventDispatcher\Event; +use OCP\EventDispatcher\IEventListener; +use OCP\Files\Events\Node\BeforeNodeDeletedEvent; use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\NotFoundException; @@ -62,7 +66,7 @@ use OCP\Lock\LockedException; use Psr\Log\LoggerInterface; -class Trashbin { +class Trashbin implements IEventListener { // unit: percentage; 50% of available disk space/quota public const DEFAULTMAXSIZE = 50; @@ -77,14 +81,12 @@ class Trashbin { /** * Ensure we don't need to scan the file during the move to trash * by triggering the scan in the pre-hook - * - * @param array $params */ - public static function ensureFileScannedHook($params) { + public static function ensureFileScannedHook(Node $node): void { try { - self::getUidAndFilename($params['path']); + self::getUidAndFilename($node->getPath()); } catch (NotFoundException $e) { - // nothing to scan for non existing files + // Nothing to scan for non existing files } } @@ -1142,4 +1144,11 @@ public static function isEmpty($user) { public static function preview_icon($path) { return \OC::$server->getURLGenerator()->linkToRoute('core_ajax_trashbin_preview', ['x' => 32, 'y' => 32, 'file' => $path]); } + + public function handle(Event $event): void { + if ($event instanceof BeforeNodeDeletedEvent) { + self::ensureFileScannedHook($event->getNode()); + + } + } } diff --git a/apps/files_trashbin/tests/StorageTest.php b/apps/files_trashbin/tests/StorageTest.php index 0a7a129ca28d2..621bb58e44092 100644 --- a/apps/files_trashbin/tests/StorageTest.php +++ b/apps/files_trashbin/tests/StorageTest.php @@ -46,10 +46,10 @@ use OCP\Files\IRootFolder; use OCP\Files\Node; use OCP\Files\Storage\IStorage; -use OCP\ILogger; use OCP\IUserManager; use OCP\Lock\ILockingProvider; use OCP\Share\IShare; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\Traits\MountProviderTrait; @@ -571,7 +571,7 @@ public function testShouldMoveToTrash($mountPoint, $path, $userExists, $appDisab ->disableOriginalConstructor()->getMock(); $userManager->expects($this->any()) ->method('userExists')->willReturn($userExists); - $logger = $this->getMockBuilder(ILogger::class)->getMock(); + $logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); $eventDispatcher = $this->createMock(EventDispatcherInterface::class); $rootFolder = $this->createMock(IRootFolder::class); $userFolder = $this->createMock(Folder::class); diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index d08312ad78963..5d85fa2ff1cbb 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -1687,9 +1687,6 @@ 'OCA\Files_Trashbin::moveToTrash' - - $this->mountPoint - dispatch diff --git a/lib/composer/autoload.php b/lib/composer/autoload.php index 6de0160c0b5b4..a3d144b1777de 100644 --- a/lib/composer/autoload.php +++ b/lib/composer/autoload.php @@ -2,6 +2,11 @@ // autoload.php @generated by Composer +if (PHP_VERSION_ID < 50600) { + echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; + exit(1); +} + require_once __DIR__ . '/composer/autoload_real.php'; return ComposerAutoloaderInit53792487c5a8370acc0b06b1a864ff4c::getLoader(); diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 3ad0b54435df7..6246651440f2f 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -260,6 +260,7 @@ 'OCP\\Files\\EmptyFileNameException' => $baseDir . '/lib/public/Files/EmptyFileNameException.php', 'OCP\\Files\\EntityTooLargeException' => $baseDir . '/lib/public/Files/EntityTooLargeException.php', 'OCP\\Files\\Events\\BeforeFileScannedEvent' => $baseDir . '/lib/public/Files/Events/BeforeFileScannedEvent.php', + 'OCP\\Files\\Events\\BeforeFileSystemSetupEvent' => $baseDir . '/lib/public/Files/Events/BeforeFileSystemSetupEvent.php', 'OCP\\Files\\Events\\BeforeFolderScannedEvent' => $baseDir . '/lib/public/Files/Events/BeforeFolderScannedEvent.php', 'OCP\\Files\\Events\\FileCacheUpdated' => $baseDir . '/lib/public/Files/Events/FileCacheUpdated.php', 'OCP\\Files\\Events\\FileScannedEvent' => $baseDir . '/lib/public/Files/Events/FileScannedEvent.php', @@ -911,6 +912,7 @@ 'OC\\Core\\Command\\Maintenance\\Repair' => $baseDir . '/core/Command/Maintenance/Repair.php', 'OC\\Core\\Command\\Maintenance\\UpdateHtaccess' => $baseDir . '/core/Command/Maintenance/UpdateHtaccess.php', 'OC\\Core\\Command\\Maintenance\\UpdateTheme' => $baseDir . '/core/Command/Maintenance/UpdateTheme.php', + 'OC\\Core\\Command\\Preview\\Regenerate' => $baseDir . '/core/Command/Preview/Regenerate.php', 'OC\\Core\\Command\\Preview\\Repair' => $baseDir . '/core/Command/Preview/Repair.php', 'OC\\Core\\Command\\Preview\\ResetRenderedTexts' => $baseDir . '/core/Command/Preview/ResetRenderedTexts.php', 'OC\\Core\\Command\\Security\\ImportCertificate' => $baseDir . '/core/Command/Security/ImportCertificate.php', diff --git a/lib/composer/composer/autoload_real.php b/lib/composer/composer/autoload_real.php index 9399510b98507..d0ab28542027c 100644 --- a/lib/composer/composer/autoload_real.php +++ b/lib/composer/composer/autoload_real.php @@ -29,7 +29,7 @@ public static function getLoader() spl_autoload_unregister(array('ComposerAutoloaderInit53792487c5a8370acc0b06b1a864ff4c', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - \Composer\Autoload\ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c::getInitializer($loader)(); + call_user_func(\Composer\Autoload\ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c::getInitializer($loader)); $loader->register(true); diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 9e04858cc5343..03613f1718c72 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -289,6 +289,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\Files\\EmptyFileNameException' => __DIR__ . '/../../..' . '/lib/public/Files/EmptyFileNameException.php', 'OCP\\Files\\EntityTooLargeException' => __DIR__ . '/../../..' . '/lib/public/Files/EntityTooLargeException.php', 'OCP\\Files\\Events\\BeforeFileScannedEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Events/BeforeFileScannedEvent.php', + 'OCP\\Files\\Events\\BeforeFileSystemSetupEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Events/BeforeFileSystemSetupEvent.php', 'OCP\\Files\\Events\\BeforeFolderScannedEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Events/BeforeFolderScannedEvent.php', 'OCP\\Files\\Events\\FileCacheUpdated' => __DIR__ . '/../../..' . '/lib/public/Files/Events/FileCacheUpdated.php', 'OCP\\Files\\Events\\FileScannedEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Events/FileScannedEvent.php', @@ -940,6 +941,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Core\\Command\\Maintenance\\Repair' => __DIR__ . '/../../..' . '/core/Command/Maintenance/Repair.php', 'OC\\Core\\Command\\Maintenance\\UpdateHtaccess' => __DIR__ . '/../../..' . '/core/Command/Maintenance/UpdateHtaccess.php', 'OC\\Core\\Command\\Maintenance\\UpdateTheme' => __DIR__ . '/../../..' . '/core/Command/Maintenance/UpdateTheme.php', + 'OC\\Core\\Command\\Preview\\Regenerate' => __DIR__ . '/../../..' . '/core/Command/Preview/Regenerate.php', 'OC\\Core\\Command\\Preview\\Repair' => __DIR__ . '/../../..' . '/core/Command/Preview/Repair.php', 'OC\\Core\\Command\\Preview\\ResetRenderedTexts' => __DIR__ . '/../../..' . '/core/Command/Preview/ResetRenderedTexts.php', 'OC\\Core\\Command\\Security\\ImportCertificate' => __DIR__ . '/../../..' . '/core/Command/Security/ImportCertificate.php', diff --git a/lib/private/Files/SetupManager.php b/lib/private/Files/SetupManager.php index f1799798ccb0a..572e4710ba3d6 100644 --- a/lib/private/Files/SetupManager.php +++ b/lib/private/Files/SetupManager.php @@ -43,6 +43,7 @@ use OCP\Files\Config\IHomeMountProvider; use OCP\Files\Config\IMountProvider; use OCP\Files\Config\IUserMountCache; +use OCP\Files\Events\BeforeFileSystemSetupEvent; use OCP\Files\Events\InvalidateMountCacheEvent; use OCP\Files\Events\Node\FilesystemTornDownEvent; use OCP\Files\Mount\IMountManager; @@ -82,6 +83,7 @@ class SetupManager { private IConfig $config; private bool $listeningForProviders; private array $fullSetupRequired = []; + private IEventDispatcher $dispatcher; public function __construct( IEventLogger $eventLogger, @@ -94,7 +96,8 @@ public function __construct( IUserSession $userSession, ICacheFactory $cacheFactory, LoggerInterface $logger, - IConfig $config + IConfig $config, + IEventDispatcher $dispatcher ) { $this->eventLogger = $eventLogger; $this->mountProviderCollection = $mountProviderCollection; @@ -108,6 +111,7 @@ public function __construct( $this->cache = $cacheFactory->createDistributed('setupmanager::'); $this->listeningForProviders = false; $this->config = $config; + $this->dispatcher = $dispatcher; $this->setupListeners(); } @@ -223,8 +227,12 @@ private function oneTimeUserSetup(IUser $user) { $this->setupUsers[] = $user->getUID(); $prevLogging = Filesystem::logWarningWhenAddingStorageWrapper(false); + // TODO remove hook OC_Hook::emit('OC_Filesystem', 'preSetup', ['user' => $user->getUID()]); + $event = new BeforeFileSystemSetupEvent($user); + $this->dispatcher->dispatchTyped($event); + Filesystem::logWarningWhenAddingStorageWrapper($prevLogging); $userDir = '/' . $user->getUID() . '/files'; diff --git a/lib/private/Files/SetupManagerFactory.php b/lib/private/Files/SetupManagerFactory.php index 1d9efbd411fbe..44954bcacaa1e 100644 --- a/lib/private/Files/SetupManagerFactory.php +++ b/lib/private/Files/SetupManagerFactory.php @@ -47,6 +47,7 @@ class SetupManagerFactory { private ICacheFactory $cacheFactory; private LoggerInterface $logger; private IConfig $config; + private IEventDispatcher $dispatcher; public function __construct( IEventLogger $eventLogger, @@ -58,7 +59,8 @@ public function __construct( IUserSession $userSession, ICacheFactory $cacheFactory, LoggerInterface $logger, - IConfig $config + IConfig $config, + IEventDispatcher $dispatcher ) { $this->eventLogger = $eventLogger; $this->mountProviderCollection = $mountProviderCollection; @@ -71,6 +73,7 @@ public function __construct( $this->logger = $logger; $this->config = $config; $this->setupManager = null; + $this->dispatcher = $dispatcher; } public function create(IMountManager $mountManager): SetupManager { @@ -86,7 +89,8 @@ public function create(IMountManager $mountManager): SetupManager { $this->userSession, $this->cacheFactory, $this->logger, - $this->config + $this->config, + $this->dispatcher, ); } return $this->setupManager; diff --git a/lib/public/Files/Events/BeforeFileSystemSetupEvent.php b/lib/public/Files/Events/BeforeFileSystemSetupEvent.php new file mode 100644 index 0000000000000..b7022fe23009e --- /dev/null +++ b/lib/public/Files/Events/BeforeFileSystemSetupEvent.php @@ -0,0 +1,52 @@ + + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCP\Files\Events; + +use OCP\EventDispatcher\Event; +use OCP\IUser; + +/** + * Event triggered before the file system is setup + * + * @since 25.0.0 + */ +class BeforeFileSystemSetupEvent extends Event { + private IUser $user; + + /** + * @since 25.0.0 + */ + public function __construct(IUser $user) { + parent::__construct(); + $this->user = $user; + } + + /** + * @since 25.0.0 + */ + public function getUser(): IUser { + return $this->user; + } +}