Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-01-07 16:00:48 +0300
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2022-01-14 17:16:59 +0300
commit805257e5ade9845a4e1ffb8dc0ec24e81ed9a7b4 (patch)
tree53eea7c9b54fb1d92e2d895d6f14fd963c53db88 /apps
parentac19acc9ad76a36e7705a64127a8603628711729 (diff)
Optimize FileSystemTags workflow for groupfolder
In https://github.com/nextcloud/server/pull/28774 we disabled the caching for the groupfolder application since it worked due to the fact that in groupfolders, getFileIds could be called with the same $cacheId and path for actually different groupfolders. This revert this change and instead add the folderId from the groupFolder to the cacheId. This solve the issue of the uniqueness of the cacheId inside GroupFolder. Downside is that we introduce groupfolder specific implementation inside the server repo. The seconf optimization is to not consider paths starting with __groupfolders in executeCheck. This is due to the fact that files in the groupfolder application call two times executeCheck one time with the url __groupfolder/<folderId>/<path> and the other time with <path>. The first time will always return an empty systemTags array while the second call will return the correct system tags. Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'apps')
-rw-r--r--apps/workflowengine/lib/Check/FileSystemTags.php38
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;
}