From e87c81734425f5c324fb669053a629386c09995e Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 29 Nov 2024 18:02:51 +0100 Subject: [PATCH 1/2] perf: improve performance of SharedStorage::getWatcher Signed-off-by: Robin Appelman [skip ci] --- apps/files_sharing/lib/SharedStorage.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index db3ffcc58461f..0fb4e230c3937 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -33,6 +33,7 @@ namespace OCA\Files_Sharing; use OC\Files\Cache\CacheDependencies; +use OC\Files\Cache\CacheEntry; use OC\Files\Cache\FailedCache; use OC\Files\Cache\NullWatcher; use OC\Files\Cache\Watcher; @@ -481,17 +482,13 @@ public function getWatcher($path = '', $storage = null): Watcher { // Get node information $node = $this->getShare()->getNodeCacheEntry(); - if ($node) { - /** @var IUserMountCache $userMountCache */ - $userMountCache = \OC::$server->get(IUserMountCache::class); - $mounts = $userMountCache->getMountsForStorageId($node->getStorageId()); - foreach ($mounts as $mount) { - // If the share is originating from an external storage - if ($mount->getMountProvider() === ConfigAdapter::class) { - // Propagate original storage scan - $this->watcher = parent::getWatcher($path, $storage); - return $this->watcher; - } + if ($node instanceof CacheEntry) { + $storageId = $node->getData()['storage_string_id']; + // for shares from the home storage we can rely on the home storage to keep itself up to date + // for other storages we need use the proper watcher + if (!(str_starts_with($storageId, 'home::') || str_starts_with($storageId, 'object::user'))) { + $this->watcher = parent::getWatcher($path, $storage); + return $this->watcher; } } From 3078aeef63602d07dc6c9aac122ca654f11686e5 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 29 Nov 2024 18:02:51 +0100 Subject: [PATCH 2/2] perf: improve performance of SharedStorage::getWatcher Signed-off-by: Robin Appelman --- apps/files_sharing/lib/SharedStorage.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index 0fb4e230c3937..90602f1a59cd1 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -44,14 +44,11 @@ use OC\Files\Storage\Wrapper\PermissionsMask; use OC\Files\Storage\Wrapper\Wrapper; use OC\User\NoUserException; -use OCA\Files_External\Config\ConfigAdapter; use OCP\Constants; use OCP\Files\Cache\ICacheEntry; -use OCP\Files\Config\IUserMountCache; use OCP\Files\Folder; use OCP\Files\IHomeStorage; use OCP\Files\IRootFolder; -use OCP\Files\Node; use OCP\Files\NotFoundException; use OCP\Files\Storage\IDisableEncryptionStorage; use OCP\Files\Storage\IStorage;