Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add helper method in Wrapper
Signed-off-by: Carl Schwan <[email protected]>
  • Loading branch information
CarlSchwan authored and backportbot[bot] committed Jan 14, 2022
commit 73e402f71517dbccf686fc9053126bc377080f72
17 changes: 5 additions & 12 deletions apps/workflowengine/lib/Check/FileSystemTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ public function __construct(IL10N $l, ISystemTagManager $systemTagManager, ISyst
* @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);
}
Expand Down Expand Up @@ -138,13 +133,11 @@ protected function getFileIds(ICache $cache, $path, $isExternalStorage) {
// 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();
Expand Down
21 changes: 20 additions & 1 deletion lib/private/Files/Storage/Wrapper/Wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ public function isLocal() {
/**
* 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) {
Expand All @@ -498,6 +498,25 @@ public function instanceOfStorage($class) {
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
*
Expand Down