Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable29] perf: improve performance of SharedStorage::getWatcher #49614

Open
wants to merge 2 commits into
base: stable29
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions apps/files_sharing/lib/SharedStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}

Expand Down