Skip to content

Commit 1a52535

Browse files
Merge pull request #50812 from nextcloud/backport/50769/stable31
[stable31] fix(SharedStorage): Check if storage ID is set on cache
2 parents 08e3e21 + b2b37ba commit 1a52535

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

apps/files_sharing/lib/SharedStorage.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
use OCP\Files\Storage\ISharedStorage;
3737
use OCP\Files\Storage\IStorage;
3838
use OCP\Lock\ILockingProvider;
39+
use OCP\Server;
3940
use OCP\Share\IShare;
4041
use OCP\Util;
4142
use Psr\Log\LoggerInterface;
@@ -90,7 +91,7 @@ class SharedStorage extends Jail implements LegacyISharedStorage, ISharedStorage
9091

9192
public function __construct(array $parameters) {
9293
$this->ownerView = $parameters['ownerView'];
93-
$this->logger = \OC::$server->get(LoggerInterface::class);
94+
$this->logger = Server::get(LoggerInterface::class);
9495

9596
$this->superShare = $parameters['superShare'];
9697
$this->groupedShares = $parameters['groupedShares'];
@@ -150,7 +151,7 @@ private function init() {
150151
}
151152

152153
/** @var IRootFolder $rootFolder */
153-
$rootFolder = \OC::$server->get(IRootFolder::class);
154+
$rootFolder = Server::get(IRootFolder::class);
154155
$this->ownerUserFolder = $rootFolder->getUserFolder($this->superShare->getShareOwner());
155156
$sourceId = $this->superShare->getNodeId();
156157
$ownerNodes = $this->ownerUserFolder->getById($sourceId);
@@ -412,7 +413,7 @@ public function getCache(string $path = '', ?IStorage $storage = null): ICache {
412413
$this->cache = new Cache(
413414
$storage,
414415
$sourceRoot,
415-
\OC::$server->get(CacheDependencies::class),
416+
Server::get(CacheDependencies::class),
416417
$this->getShare()
417418
);
418419
return $this->cache;
@@ -437,16 +438,15 @@ public function getWatcher(string $path = '', ?IStorage $storage = null): IWatch
437438
// Get node information
438439
$node = $this->getShare()->getNodeCacheEntry();
439440
if ($node instanceof CacheEntry) {
440-
$storageId = $node->getData()['storage_string_id'];
441+
$storageId = $node->getData()['storage_string_id'] ?? null;
441442
// for shares from the home storage we can rely on the home storage to keep itself up to date
442443
// for other storages we need use the proper watcher
443-
if (!(str_starts_with($storageId, 'home::') || str_starts_with($storageId, 'object::user'))) {
444+
if ($storageId !== null && !(str_starts_with($storageId, 'home::') || str_starts_with($storageId, 'object::user'))) {
444445
$cache = $this->getCache();
445446
$this->watcher = parent::getWatcher($path, $storage);
446447
if ($cache instanceof Cache) {
447448
$this->watcher->onUpdate($cache->markRootChanged(...));
448449
}
449-
450450
return $this->watcher;
451451
}
452452
}

0 commit comments

Comments
 (0)