diff options
-rw-r--r-- | apps/workflowengine/lib/Check/FileSystemTags.php | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/apps/workflowengine/lib/Check/FileSystemTags.php b/apps/workflowengine/lib/Check/FileSystemTags.php index c5f32bbb4e7..f2b9b2a186b 100644 --- a/apps/workflowengine/lib/Check/FileSystemTags.php +++ b/apps/workflowengine/lib/Check/FileSystemTags.php @@ -36,6 +36,7 @@ use OCP\SystemTag\ISystemTagObjectMapper; use OCP\SystemTag\TagNotFoundException; use OCP\WorkflowEngine\ICheck; use OCP\WorkflowEngine\IFileCheck; +use OC\Files\Storage\Wrapper\Wrapper; class FileSystemTags implements ICheck, IFileCheck { use TFileCheck; @@ -72,6 +73,11 @@ class FileSystemTags implements ICheck, IFileCheck { * @return bool */ public function executeCheck($operator, $value) { + if (str_starts_with($this->path, '__groupfolders')) { + // System tags are always empty in this case and executeCheck is called + // a second time with the jailedPath + return false; + } $systemTags = $this->getSystemTags(); return ($operator === 'is') === in_array($value, $systemTags); } @@ -132,13 +138,29 @@ class FileSystemTags implements ICheck, IFileCheck { * @return int[] */ protected function getFileIds(ICache $cache, $path, $isExternalStorage) { - // TODO: Fix caching inside group folders - // Do not cache file ids inside group folders because multiple file ids might be mapped to - // the same combination of cache id + path. /** @psalm-suppress InvalidArgument */ - $shouldCacheFileIds = !$this->storage->instanceOfStorage(\OCA\GroupFolders\Mount\GroupFolderStorage::class); - $cacheId = $cache->getNumericStorageId(); - if ($shouldCacheFileIds && isset($this->fileIds[$cacheId][$path])) { + if ($this->storage->instanceOfStorage(\OCA\GroupFolders\Mount\GroupFolderStorage::class)) { + static $groupFolderStorage = null; + if ($groupFolderStorage === null) { + // Special implementation for groupfolder since all groupfolder chare the same storage + // so add the group folder id in the cache key too. + $groupFolderStorage = $this->storage; + $groupFolderStoragClass = \OCA\GroupFolders\Mount\GroupFolderStorage::class; + while ($groupFolderStorage->instanceOfStorage(Wrapper::class)) { + if ($groupFolderStorage instanceof $groupFolderStoragClass) { + break; + } + /** + * @var Wrapper $sourceStorage + */ + $groupFolderStorage = $groupFolderStorage->getWrapperStorage(); + } + } + $cacheId = $cache->getNumericStorageId() . '/' . $groupFolderStorage->getFolderId(); + } else { + $cacheId = $cache->getNumericStorageId(); + } + if (isset($this->fileIds[$cacheId][$path])) { return $this->fileIds[$cacheId][$path]; } @@ -154,9 +176,7 @@ class FileSystemTags implements ICheck, IFileCheck { $parentIds[] = $cache->getId($path); } - if ($shouldCacheFileIds) { - $this->fileIds[$cacheId][$path] = $parentIds; - } + $this->fileIds[$cacheId][$path] = $parentIds; return $parentIds; } |