Skip to content

Commit

Permalink
Merge pull request #50813 from nextcloud/backport/50769/stable30
Browse files Browse the repository at this point in the history
[stable30] fix(SharedStorage): Check if storage ID is set on cache
  • Loading branch information
solracsf authored Feb 17, 2025
2 parents d0b39d1 + 59a0bc9 commit 01667ff
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions apps/files_sharing/lib/SharedStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use OCP\Files\Storage\ISharedStorage;
use OCP\Files\Storage\IStorage;
use OCP\Lock\ILockingProvider;
use OCP\Server;
use OCP\Share\IShare;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -82,7 +83,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements LegacyISha

public function __construct($arguments) {
$this->ownerView = $arguments['ownerView'];
$this->logger = \OC::$server->get(LoggerInterface::class);
$this->logger = Server::get(LoggerInterface::class);

$this->superShare = $arguments['superShare'];
$this->groupedShares = $arguments['groupedShares'];
Expand Down Expand Up @@ -142,7 +143,7 @@ private function init() {
}

/** @var IRootFolder $rootFolder */
$rootFolder = \OC::$server->get(IRootFolder::class);
$rootFolder = Server::get(IRootFolder::class);
$this->ownerUserFolder = $rootFolder->getUserFolder($this->superShare->getShareOwner());
$sourceId = $this->superShare->getNodeId();
$ownerNodes = $this->ownerUserFolder->getById($sourceId);
Expand Down Expand Up @@ -431,7 +432,7 @@ public function getCache($path = '', $storage = null) {
$this->cache = new \OCA\Files_Sharing\Cache(
$storage,
$sourceRoot,
\OC::$server->get(CacheDependencies::class),
Server::get(CacheDependencies::class),
$this->getShare()
);
return $this->cache;
Expand All @@ -456,16 +457,15 @@ public function getWatcher($path = '', $storage = null): Watcher {
// Get node information
$node = $this->getShare()->getNodeCacheEntry();
if ($node instanceof CacheEntry) {
$storageId = $node->getData()['storage_string_id'];
$storageId = $node->getData()['storage_string_id'] ?? null;
// 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'))) {
if ($storageId !== null && !(str_starts_with($storageId, 'home::') || str_starts_with($storageId, 'object::user'))) {
$cache = $this->getCache();
$this->watcher = parent::getWatcher($path, $storage);
if ($cache instanceof Cache && $this->watcher instanceof Watcher) {
$this->watcher->onUpdate([$cache, 'markRootChanged']);
}

return $this->watcher;
}
}
Expand Down

0 comments on commit 01667ff

Please sign in to comment.