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
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-01-10 13:36:51 +0300
committerCarl Schwan <carl@carlschwan.eu>2022-01-13 12:39:36 +0300
commit695165260f26b2f5b5584e619e54741db1a2d9cc (patch)
treef54ef011bcdc40a4062d03e3a866cf55be14531f
parent0479fff37cb08157d982c593ce21fb79957e8574 (diff)
Add helper method in Wrapper
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
-rw-r--r--apps/workflowengine/lib/Check/FileSystemTags.php17
-rw-r--r--lib/private/Files/Storage/Wrapper/Wrapper.php21
2 files changed, 25 insertions, 13 deletions
diff --git a/apps/workflowengine/lib/Check/FileSystemTags.php b/apps/workflowengine/lib/Check/FileSystemTags.php
index b6ad95a4ab6..d3f02729f2f 100644
--- a/apps/workflowengine/lib/Check/FileSystemTags.php
+++ b/apps/workflowengine/lib/Check/FileSystemTags.php
@@ -73,11 +73,6 @@ 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);
}
@@ -143,13 +138,11 @@ class FileSystemTags implements ICheck, IFileCheck {
// 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;
- $groupFolderStorageClass = \OCA\GroupFolders\Mount\GroupFolderStorage::class;
- while ($groupFolderStorage->instanceOfStorage(Wrapper::class)) {
- if ($groupFolderStorage instanceof $groupFolderStorageClass) {
- break;
- }
- /** @var Wrapper $groupFolderStorage */
- $groupFolderStorage = $groupFolderStorage->getWrapperStorage();
+ 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 UndefinedMethod */
$cacheId = $cache->getNumericStorageId() . '/' . $groupFolderStorage->getFolderId();
diff --git a/lib/private/Files/Storage/Wrapper/Wrapper.php b/lib/private/Files/Storage/Wrapper/Wrapper.php
index 5faffece67e..b44db7c13ce 100644
--- a/lib/private/Files/Storage/Wrapper/Wrapper.php
+++ b/lib/private/Files/Storage/Wrapper/Wrapper.php
@@ -486,7 +486,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea
/**
* Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class
*
- * @param string $class
+ * @param class-string<IStorage> $class
* @return bool
*/
public function instanceOfStorage($class) {
@@ -498,6 +498,25 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea
}
/**
+ * @template T of IStorage
+ * @param class-string<T> $class
+ * @return ?T
+ */
+ public function getInstanceOfStorage(string $class): ?IStorage {
+ $storage = $this;
+ while ($storage->instanceOfStorage(Wrapper::class)) {
+ if ($storage instanceof $class) {
+ break;
+ }
+ $storage = $storage->getWrapperStorage();
+ }
+ if (!is_a($storage, $class)) {
+ return null;
+ }
+ return $storage;
+ }
+
+ /**
* Pass any methods custom to specific storage implementations to the wrapped storage
*
* @param string $method