Skip to content

Commit

Permalink
fix(workflows): Fix file systemtag cache
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Jul 10, 2024
1 parent cd7007c commit 738c153
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions apps/workflowengine/lib/Check/FileSystemTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
namespace OCA\WorkflowEngine\Check;

use OC\Files\Storage\Wrapper\Wrapper;
use OC\Files\Storage\Wrapper\Jail;
use OCA\Files_Sharing\SharedStorage;
use OCA\WorkflowEngine\Entity\File;
use OCP\Files\Cache\ICache;
Expand Down Expand Up @@ -133,27 +133,17 @@ protected function getSystemTags() {
* @return int[]
*/
protected function getFileIds(ICache $cache, $path, $isExternalStorage) {
/** @psalm-suppress InvalidArgument */
if ($this->storage->instanceOfStorage(\OCA\GroupFolders\Mount\GroupFolderStorage::class)) {
// Special implementation for groupfolder since all groupfolders share the same storage
// id so add the group folder id in the cache key too.
$groupFolderStorage = $this->storage;
if ($this->storage instanceof Wrapper) {
$groupFolderStorage = $this->storage->getInstanceOfStorage(\OCA\GroupFolders\Mount\GroupFolderStorage::class);
}
if ($groupFolderStorage === null) {
throw new \LogicException('Should not happen: Storage is instance of GroupFolderStorage but no group folder storage found while unwrapping.');
}
/**
* @psalm-suppress UndefinedDocblockClass
* @psalm-suppress UndefinedInterfaceMethod
*/
$cacheId = $cache->getNumericStorageId() . '/' . $groupFolderStorage->getFolderId();
if ($this->storage->instanceOfStorage(Jail::class)) {
$absolutePath = $this->storage->getUnjailedPath($path);
$cacheId = $cache->getNumericStorageId();
} elseif ($this->storage->instanceOfStorage(Jail::class)) {
$cacheId = $cache->getNumericStorageId() . '/' . $this->storage->getUnjailedPath('');
} else {
$absolutePath = $path;
$cacheId = $cache->getNumericStorageId();
}
if (isset($this->fileIds[$cacheId][$path])) {
return $this->fileIds[$cacheId][$path];
if (isset($this->fileIds[$cacheId][$absolutePath])) {

Check notice

Code scanning / Psalm

PossiblyUndefinedVariable Note

Possibly undefined variable $absolutePath, first seen on line 137
return $this->fileIds[$cacheId][$absolutePath];

Check notice

Code scanning / Psalm

PossiblyUndefinedVariable Note

Possibly undefined variable $absolutePath, first seen on line 137
}

$parentIds = [];
Expand All @@ -168,7 +158,7 @@ protected function getFileIds(ICache $cache, $path, $isExternalStorage) {
$parentIds[] = $fileId;
}

$this->fileIds[$cacheId][$path] = $parentIds;
$this->fileIds[$cacheId][$absolutePath] = $parentIds;

Check notice

Code scanning / Psalm

PossiblyUndefinedVariable Note

Possibly undefined variable $absolutePath, first seen on line 137

return $parentIds;
}
Expand Down

0 comments on commit 738c153

Please sign in to comment.