Skip to content

Commit ab01174

Browse files
committed
Fix psalm issues
Signed-off-by: Carl Schwan <[email protected]>
1 parent 33f49b1 commit ab01174

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

apps/workflowengine/lib/Check/FileSystemTags.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,26 @@ protected function getSystemTags() {
128128
* @return int[]
129129
*/
130130
protected function getFileIds(ICache $cache, $path, $isExternalStorage) {
131-
// TODO: Fix caching inside group folders
132-
// Do not cache file ids inside group folders because multiple file ids might be mapped to
133-
// the same combination of cache id + path.
134-
$shouldCacheFileIds = !$this->storage
135-
->instanceOfStorage(\OCA\GroupFolders\Mount\GroupFolderStorage::class);
136-
$cacheId = $cache->getNumericStorageId();
137-
if ($shouldCacheFileIds && isset($this->fileIds[$cacheId][$path])) {
131+
if ($this->storage->instanceOfStorage(\OCA\GroupFolders\Mount\GroupFolderStorage::class)) {
132+
// Special implementation for groupfolder since all groupfolders share the same storage
133+
// id so add the group folder id in the cache key too.
134+
$groupFolderStorage = $this->storage;
135+
if ($this->storage instanceof Wrapper) {
136+
$groupFolderStorage = $this->storage->getInstanceOfStorage(\OCA\GroupFolders\Mount\GroupFolderStorage::class);
137+
}
138+
if ($groupFolderStorage === null) {
139+
throw new \LogicException('Should not happen: Storage is instance of GroupFolderStorage but no group folder storage found while unwrapping.');
140+
}
141+
/**
142+
* @psalm-suppress UndefinedDocblockClass
143+
* @psalm-suppress UndefinedInterfaceMethod
144+
*/
145+
$cacheId = $cache->getNumericStorageId() . '/' . $groupFolderStorage->getFolderId();
146+
This conversation was marked as resolved by CarlSchwan
147+
} else {
148+
$cacheId = $cache->getNumericStorageId();
149+
}
150+
if (isset($this->fileIds[$cacheId][$path])) {
138151
return $this->fileIds[$cacheId][$path];
139152
}
140153

lib/private/Files/Storage/Wrapper/Wrapper.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -497,19 +497,19 @@ public function instanceOfStorage($class) {
497497
}
498498

499499
/**
500-
* @template T of IStorage
501-
* @param class-string<T> $class
502-
* @return ?T
500+
* @psalm-template T of IStorage
501+
* @psalm-param class-string<T> $class
502+
* @psalm-return T|null
503503
*/
504-
public function getInstanceOfStorage(string $class): ?IStorage {
504+
public function getInstanceOfStorage(string $class) {
505505
$storage = $this;
506-
while ($storage->instanceOfStorage(Wrapper::class)) {
506+
while ($storage instanceof Wrapper) {
507507
if ($storage instanceof $class) {
508508
break;
509509
}
510510
$storage = $storage->getWrapperStorage();
511511
}
512-
if (!is_a($storage, $class)) {
512+
if (!($storage instanceof $class)) {
513513
return null;
514514
}
515515
return $storage;

0 commit comments

Comments
 (0)