From 02dfb4ae60f706361e5de1374b6e0802127451ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 22 Apr 2024 09:16:41 +0200 Subject: [PATCH 1/2] perf(boot): Initialize storage wrapper and lock manager more lazy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/AppInfo/Application.php | 65 ++++++------------------------------- 1 file changed, 10 insertions(+), 55 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index fa70225b..764392cf 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -31,7 +31,6 @@ namespace OCA\FilesLock\AppInfo; -use Closure; use OC\Files\Filesystem; use OCA\Files\Event\LoadAdditionalScriptsEvent; use OCA\FilesLock\Capability; @@ -45,20 +44,13 @@ use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\Files\Lock\ILockManager; -use OCP\IServerContainer; use OCP\IUserSession; +use OCP\Server; use OCP\Util; -use Throwable; -/** - * Class Application - * - * @package OCA\FilesLock\AppInfo - */ class Application extends App implements IBootstrap { public const APP_ID = 'files_lock'; - public const DAV_PROPERTY_LOCK = '{http://nextcloud.org/ns}lock'; public const DAV_PROPERTY_LOCK_OWNER_TYPE = '{http://nextcloud.org/ns}lock-owner-type'; public const DAV_PROPERTY_LOCK_OWNER = '{http://nextcloud.org/ns}lock-owner'; @@ -68,30 +60,10 @@ class Application extends App implements IBootstrap { public const DAV_PROPERTY_LOCK_TIMEOUT = '{http://nextcloud.org/ns}lock-timeout'; public const DAV_PROPERTY_LOCK_TOKEN = '{http://nextcloud.org/ns}lock-token'; - - /** @var IUserSession */ - private $userSession; - - /** @var FileService */ - private $fileService; - - /** @var LockService */ - private $lockService; - - private ILockManager $lockManager; - - - /** - * @param array $params - */ public function __construct(array $params = []) { parent::__construct(self::APP_ID, $params); } - - /** - * @param IRegistrationContext $context - */ public function register(IRegistrationContext $context): void { $context->registerCapability(Capability::class); $context->registerEventListener( @@ -100,46 +72,29 @@ public function register(IRegistrationContext $context): void { ); } - - /** - * @param IBootContext $context - * - * @throws Throwable - */ public function boot(IBootContext $context): void { - $context->injectFn(Closure::fromCallable([$this, 'registerHooks'])); + $this->registerHooks(); $context->injectFn(function (ILockManager $lockManager) use ($context) { - $lockManager->registerLockProvider($context->getAppContainer()->get(LockProvider::class)); + $lockManager->registerLazyLockProvider(LockProvider::class); }); } - - /** - * @param IServerContainer $container - */ - public function registerHooks(IServerContainer $container) { - $this->userSession = $container->get(IUserSession::class); - $this->fileService = $container->get(FileService::class); - $this->lockService = $container->get(LockService::class); - $this->lockManager = $container->get(ILockManager::class); - + public function registerHooks(): void { Util::connectHook('OC_Filesystem', 'preSetup', $this, 'addStorageWrapper'); } - /** - * @internal - */ - public function addStorageWrapper() { + /** @internal */ + public function addStorageWrapper(): void { Filesystem::addStorageWrapper( 'files_lock', function ($mountPoint, $storage) { return new LockWrapper( [ 'storage' => $storage, - 'lock_manager' => $this->lockManager, - 'user_session' => $this->userSession, - 'file_service' => $this->fileService, - 'lock_service' => $this->lockService + 'lock_manager' => Server::get(ILockManager::class), + 'user_session' => Server::get(IUserSession::class), + 'file_service' => Server::get(FileService::class), + 'lock_service' => Server::get(LockService::class) ] ); }, 10 From c73ad49e212e121332236a67e1b21197b345ecdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 13 May 2024 14:26:09 +0200 Subject: [PATCH 2/2] chore(ocp): bump nextcloud/ocp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- composer.lock | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/composer.lock b/composer.lock index e1304610..23f4c31e 100644 --- a/composer.lock +++ b/composer.lock @@ -183,12 +183,12 @@ "source": { "type": "git", "url": "https://github.com/nextcloud-deps/ocp.git", - "reference": "9af4248bbeff8ff43d45195d68530fd2674b12c8" + "reference": "dab486b51ddb24e713d6eab3abb18bd2fc9bcc18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nextcloud-deps/ocp/zipball/9af4248bbeff8ff43d45195d68530fd2674b12c8", - "reference": "9af4248bbeff8ff43d45195d68530fd2674b12c8", + "url": "https://api.github.com/repos/nextcloud-deps/ocp/zipball/dab486b51ddb24e713d6eab3abb18bd2fc9bcc18", + "reference": "dab486b51ddb24e713d6eab3abb18bd2fc9bcc18", "shasum": "" }, "require": { @@ -220,7 +220,7 @@ "issues": "https://github.com/nextcloud-deps/ocp/issues", "source": "https://github.com/nextcloud-deps/ocp/tree/master" }, - "time": "2024-05-12T00:37:28+00:00" + "time": "2024-05-13T12:22:19+00:00" }, { "name": "nikic/php-parser", @@ -400,16 +400,16 @@ }, { "name": "php-cs-fixer/shim", - "version": "v3.49.0", + "version": "v3.56.1", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/shim.git", - "reference": "f7d3219cac46632f12362c9aa7c2ac0d2fe92c52" + "reference": "98c0b531f2e7a43a4da2449498398f484b29df50" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/f7d3219cac46632f12362c9aa7c2ac0d2fe92c52", - "reference": "f7d3219cac46632f12362c9aa7c2ac0d2fe92c52", + "url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/98c0b531f2e7a43a4da2449498398f484b29df50", + "reference": "98c0b531f2e7a43a4da2449498398f484b29df50", "shasum": "" }, "require": { @@ -446,9 +446,9 @@ "description": "A tool to automatically fix PHP code style", "support": { "issues": "https://github.com/PHP-CS-Fixer/shim/issues", - "source": "https://github.com/PHP-CS-Fixer/shim/tree/v3.49.0" + "source": "https://github.com/PHP-CS-Fixer/shim/tree/v3.56.1" }, - "time": "2024-02-02T00:42:09+00:00" + "time": "2024-05-10T11:31:44+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1486,16 +1486,16 @@ }, { "name": "sabre/xml", - "version": "2.2.6", + "version": "2.2.7", "source": { "type": "git", "url": "https://github.com/sabre-io/xml.git", - "reference": "9cde7cdab1e50893cc83b037b40cd47bfde42a2b" + "reference": "f1d53d55976bbd4cf3e640dda6ebc31120c71a4e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sabre-io/xml/zipball/9cde7cdab1e50893cc83b037b40cd47bfde42a2b", - "reference": "9cde7cdab1e50893cc83b037b40cd47bfde42a2b", + "url": "https://api.github.com/repos/sabre-io/xml/zipball/f1d53d55976bbd4cf3e640dda6ebc31120c71a4e", + "reference": "f1d53d55976bbd4cf3e640dda6ebc31120c71a4e", "shasum": "" }, "require": { @@ -1551,7 +1551,7 @@ "issues": "https://github.com/sabre-io/xml/issues", "source": "https://github.com/fruux/sabre-xml" }, - "time": "2023-06-28T12:56:05+00:00" + "time": "2024-04-18T10:15:43+00:00" }, { "name": "sebastian/cli-parser",