Add helper method in Wrapper

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
This commit is contained in:
Carl Schwan 2022-01-10 11:36:51 +01:00 committed by backportbot[bot]
parent 27334942ca
commit 33f49b13ed
2 changed files with 20 additions and 6 deletions

View file

@ -68,11 +68,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);
}

View file

@ -485,7 +485,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) {
@ -496,6 +496,25 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea
return is_a($this, $class) or $this->getWrapperStorage()->instanceOfStorage($class);
}
/**
* @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
*