Skip to content

Commit 150fc1e

Browse files
committed
perf: improve performance of SharedStorage::getWatcher
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 0c32d38 commit 150fc1e

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

apps/files_sharing/lib/SharedStorage.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace OCA\Files_Sharing;
88

99
use OC\Files\Cache\CacheDependencies;
10+
use OC\Files\Cache\CacheEntry;
1011
use OC\Files\Cache\FailedCache;
1112
use OC\Files\Cache\NullWatcher;
1213
use OC\Files\Cache\Watcher;
@@ -17,11 +18,9 @@
1718
use OC\Files\Storage\Wrapper\PermissionsMask;
1819
use OC\Files\Storage\Wrapper\Wrapper;
1920
use OC\User\NoUserException;
20-
use OCA\Files_External\Config\ConfigAdapter;
2121
use OCA\Files_Sharing\ISharedStorage as LegacyISharedStorage;
2222
use OCP\Constants;
2323
use OCP\Files\Cache\ICacheEntry;
24-
use OCP\Files\Config\IUserMountCache;
2524
use OCP\Files\Folder;
2625
use OCP\Files\IHomeStorage;
2726
use OCP\Files\IRootFolder;
@@ -456,17 +455,13 @@ public function getWatcher($path = '', $storage = null): Watcher {
456455

457456
// Get node information
458457
$node = $this->getShare()->getNodeCacheEntry();
459-
if ($node) {
460-
/** @var IUserMountCache $userMountCache */
461-
$userMountCache = \OC::$server->get(IUserMountCache::class);
462-
$mounts = $userMountCache->getMountsForStorageId($node->getStorageId());
463-
foreach ($mounts as $mount) {
464-
// If the share is originating from an external storage
465-
if ($mount->getMountProvider() === ConfigAdapter::class) {
466-
// Propagate original storage scan
467-
$this->watcher = parent::getWatcher($path, $storage);
468-
return $this->watcher;
469-
}
458+
if ($node instanceof CacheEntry) {
459+
$storageId = $node->getData()['storage_string_id'];
460+
// for shares from the home storage we can rely on the home storage to keep itself up to date
461+
// for other storages we need use the proper watcher
462+
if (!(str_starts_with($storageId, 'home::') || str_starts_with($storageId, 'object::user'))) {
463+
$this->watcher = parent::getWatcher($path, $storage);
464+
return $this->watcher;
470465
}
471466
}
472467

0 commit comments

Comments
 (0)