Skip to content

Commit

Permalink
fix(SharedStorage): Check if storage ID is set on cache
Browse files Browse the repository at this point in the history
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
  • Loading branch information
solracsf authored Feb 12, 2025
1 parent 167a78f commit c26a1db
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions apps/files_sharing/lib/SharedStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use OCP\Files\Storage\ISharedStorage;
use OCP\Files\Storage\IStorage;
use OCP\Lock\ILockingProvider;
use OCP\Server;
use OCP\Share\IShare;
use OCP\Util;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -90,7 +91,7 @@ class SharedStorage extends Jail implements LegacyISharedStorage, ISharedStorage

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

$this->superShare = $parameters['superShare'];
$this->groupedShares = $parameters['groupedShares'];
Expand Down Expand Up @@ -150,7 +151,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 @@ -412,7 +413,7 @@ public function getCache(string $path = '', ?IStorage $storage = null): ICache {
$this->cache = new Cache(
$storage,
$sourceRoot,
\OC::$server->get(CacheDependencies::class),
Server::get(CacheDependencies::class),
$this->getShare()
);
return $this->cache;
Expand All @@ -437,17 +438,19 @@ public function getWatcher(string $path = '', ?IStorage $storage = null): IWatch
// Get node information
$node = $this->getShare()->getNodeCacheEntry();
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'))) {
$cache = $this->getCache();
$this->watcher = parent::getWatcher($path, $storage);
if ($cache instanceof Cache) {
$this->watcher->onUpdate($cache->markRootChanged(...));
if (isset($node->getData()['storage_string_id'])) {
$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'))) {
$cache = $this->getCache();
$this->watcher = parent::getWatcher($path, $storage);
if ($cache instanceof Cache) {
$this->watcher->onUpdate($cache->markRootChanged(...));
}

return $this->watcher;
}

return $this->watcher;
}
}

Expand Down

0 comments on commit c26a1db

Please sign in to comment.