Skip to content

Commit

Permalink
fix: always regenerate availabe task types
Browse files Browse the repository at this point in the history
Signed-off-by: Jana Peper <jana.peper@nextcloud.com>
  • Loading branch information
janepie committed Dec 11, 2024
1 parent d879dde commit 7312acd
Showing 1 changed file with 32 additions and 33 deletions.
65 changes: 32 additions & 33 deletions lib/private/TaskProcessing/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,43 +733,42 @@ public function getPreferredProvider(string $taskTypeId) {
}

public function getAvailableTaskTypes(bool $showDisabled = false): array {
if ($this->availableTaskTypes === null) {
$taskTypes = $this->_getTaskTypes();
$taskTypeSettings = $this->_getTaskTypeSettings();
$taskTypes = $this->_getTaskTypes();
$taskTypeSettings = $this->_getTaskTypeSettings();

$availableTaskTypes = [];
foreach ($taskTypes as $taskType) {
if ((!$showDisabled) && isset($taskTypeSettings[$taskType->getId()]) && !$taskTypeSettings[$taskType->getId()]) {
continue;
}
try {
$provider = $this->getPreferredProvider($taskType->getId());
} catch (\OCP\TaskProcessing\Exception\Exception $e) {
continue;
}
try {
$availableTaskTypes[$provider->getTaskTypeId()] = [
'name' => $taskType->getName(),
'description' => $taskType->getDescription(),
'optionalInputShape' => $provider->getOptionalInputShape(),
'inputShapeEnumValues' => $provider->getInputShapeEnumValues(),
'inputShapeDefaults' => $provider->getInputShapeDefaults(),
'inputShape' => $taskType->getInputShape(),
'optionalInputShapeEnumValues' => $provider->getOptionalInputShapeEnumValues(),
'optionalInputShapeDefaults' => $provider->getOptionalInputShapeDefaults(),
'outputShape' => $taskType->getOutputShape(),
'outputShapeEnumValues' => $provider->getOutputShapeEnumValues(),
'optionalOutputShape' => $provider->getOptionalOutputShape(),
'optionalOutputShapeEnumValues' => $provider->getOptionalOutputShapeEnumValues(),
];
} catch (\Throwable $e) {
$this->logger->error('Failed to set up TaskProcessing provider ' . $provider::class, ['exception' => $e]);
}
$availableTaskTypes = [];
foreach ($taskTypes as $taskType) {
if ((!$showDisabled) && isset($taskTypeSettings[$taskType->getId()]) && !$taskTypeSettings[$taskType->getId()]) {
continue;
}
try {
$provider = $this->getPreferredProvider($taskType->getId());
} catch (\OCP\TaskProcessing\Exception\Exception $e) {
continue;
}
try {
$availableTaskTypes[$provider->getTaskTypeId()] = [
'name' => $taskType->getName(),
'description' => $taskType->getDescription(),
'optionalInputShape' => $provider->getOptionalInputShape(),
'inputShapeEnumValues' => $provider->getInputShapeEnumValues(),
'inputShapeDefaults' => $provider->getInputShapeDefaults(),
'inputShape' => $taskType->getInputShape(),
'optionalInputShapeEnumValues' => $provider->getOptionalInputShapeEnumValues(),
'optionalInputShapeDefaults' => $provider->getOptionalInputShapeDefaults(),
'outputShape' => $taskType->getOutputShape(),
'outputShapeEnumValues' => $provider->getOutputShapeEnumValues(),
'optionalOutputShape' => $provider->getOptionalOutputShape(),
'optionalOutputShapeEnumValues' => $provider->getOptionalOutputShapeEnumValues(),
];
} catch (\Throwable $e) {
$this->logger->error('Failed to set up TaskProcessing provider ' . $provider::class, ['exception' => $e]);
}

$this->availableTaskTypes = $availableTaskTypes;
}

$this->availableTaskTypes = $availableTaskTypes;


return $this->availableTaskTypes;
}

Expand Down

0 comments on commit 7312acd

Please sign in to comment.