mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
fix: address review comments
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
parent
5de42a53e2
commit
2c878099f1
6 changed files with 30 additions and 13 deletions
|
|
@ -183,9 +183,9 @@ class TaskProcessingApiController extends \OCP\AppFramework\OCSController {
|
|||
|
||||
$this->taskProcessingManager->deleteTask($task);
|
||||
|
||||
return new DataResponse([]);
|
||||
return new DataResponse(null);
|
||||
} catch (\OCP\TaskProcessing\Exception\NotFoundException $e) {
|
||||
return new DataResponse([]);
|
||||
return new DataResponse(null);
|
||||
} catch (\OCP\TaskProcessing\Exception\Exception $e) {
|
||||
return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
|
@ -272,20 +272,22 @@ class TaskProcessingApiController extends \OCP\AppFramework\OCSController {
|
|||
$taskType = $taskTypes[$task->getTaskTypeId()];
|
||||
foreach ($taskType['inputShape'] + $taskType['optionalInputShape'] as $key => $descriptor) {
|
||||
if (in_array(EShapeType::getScalarType($descriptor->getShapeType()), [EShapeType::File, EShapeType::Image, EShapeType::Audio, EShapeType::Video], true)) {
|
||||
if (is_array($task->getInput()[$key])) {
|
||||
$ids += $task->getInput()[$key];
|
||||
$inputSlot = $task->getInput()[$key];
|
||||
if (is_array($inputSlot)) {
|
||||
$ids += $inputSlot;
|
||||
} else {
|
||||
$ids[] = $task->getInput()[$key];
|
||||
$ids[] = $inputSlot;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($task->getOutput() !== null) {
|
||||
foreach ($taskType['outputShape'] + $taskType['optionalOutputShape'] as $key => $descriptor) {
|
||||
if (in_array(EShapeType::getScalarType($descriptor->getShapeType()), [EShapeType::File, EShapeType::Image, EShapeType::Audio, EShapeType::Video], true)) {
|
||||
if (is_array($task->getInput()[$key])) {
|
||||
$ids += $task->getOutput()[$key];
|
||||
$outputSlot = $task->getOutput()[$key];
|
||||
if (is_array($outputSlot)) {
|
||||
$ids += $outputSlot;
|
||||
} else {
|
||||
$ids[] = $task->getOutput()[$key];
|
||||
$ids[] = $outputSlot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -338,7 +340,9 @@ class TaskProcessingApiController extends \OCP\AppFramework\OCSController {
|
|||
#[ApiRoute(verb: 'POST', url: '/tasks/{taskId}/result', root: '/taskprocessing')]
|
||||
public function setResult(int $taskId, ?array $output = null, ?string $errorMessage = null): DataResponse {
|
||||
try {
|
||||
// Check if the current user can access the task
|
||||
$this->taskProcessingManager->getUserTask($taskId, $this->userId);
|
||||
// set result
|
||||
$this->taskProcessingManager->setTaskResult($taskId, $errorMessage, $output);
|
||||
$task = $this->taskProcessingManager->getUserTask($taskId, $this->userId);
|
||||
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ namespace OCA\Core;
|
|||
* }
|
||||
*
|
||||
* @psalm-type CoreTaskProcessingTask = array{
|
||||
* id: ?int,
|
||||
* id: int,
|
||||
* type: string,
|
||||
* status: 0|1|2|3|4|5,
|
||||
* userId: ?string,
|
||||
|
|
|
|||
|
|
@ -503,8 +503,7 @@
|
|||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"nullable": true
|
||||
"format": "int64"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
|
|
|
|||
|
|
@ -98,9 +98,9 @@ class Task extends Entity {
|
|||
}, self::$fields));
|
||||
}
|
||||
|
||||
public static function fromPublicTask(OCPTask $task): Task {
|
||||
public static function fromPublicTask(OCPTask $task): self {
|
||||
/** @var Task $taskEntity */
|
||||
$taskEntity = Task::fromParams([
|
||||
$taskEntity = self::fromParams([
|
||||
'id' => $task->getId(),
|
||||
'type' => $task->getTaskTypeId(),
|
||||
'lastUpdated' => time(),
|
||||
|
|
|
|||
|
|
@ -385,6 +385,9 @@ class Manager implements IManager {
|
|||
try {
|
||||
/** @var IProvider $provider */
|
||||
$provider = $this->serverContainer->get($class);
|
||||
if (isset($providers[$provider->getId()])) {
|
||||
$this->logger->warning('Task processing provider ' . $class . ' is using ID ' . $provider->getId() . ' which is already used by ' . $providers[$provider->getId()]::class);
|
||||
}
|
||||
$providers[$provider->getId()] = $provider;
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->error('Failed to load task processing provider ' . $class, [
|
||||
|
|
@ -423,6 +426,9 @@ class Manager implements IManager {
|
|||
try {
|
||||
/** @var ITaskType $provider */
|
||||
$taskType = $this->serverContainer->get($class);
|
||||
if (isset($taskTypes[$taskType->getId()])) {
|
||||
$this->logger->warning('Task processing task type ' . $class . ' is using ID ' . $taskType->getId() . ' which is already used by ' . $taskTypes[$taskType->getId()]::class);
|
||||
}
|
||||
$taskTypes[$taskType->getId()] = $taskType;
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->error('Failed to load task processing task type ' . $class, [
|
||||
|
|
|
|||
|
|
@ -40,7 +40,15 @@ class RemoveOldTasksBackgroundJob extends TimedJob {
|
|||
}
|
||||
try {
|
||||
$this->clearFilesOlderThan($this->appData->getFolder('text2image'), self::MAX_TASK_AGE_SECONDS);
|
||||
} catch (NotFoundException $e) {
|
||||
// noop
|
||||
}
|
||||
try {
|
||||
$this->clearFilesOlderThan($this->appData->getFolder('audio2text'), self::MAX_TASK_AGE_SECONDS);
|
||||
} catch (NotFoundException $e) {
|
||||
// noop
|
||||
}
|
||||
try {
|
||||
$this->clearFilesOlderThan($this->appData->getFolder('TaskProcessing'), self::MAX_TASK_AGE_SECONDS);
|
||||
} catch (NotFoundException $e) {
|
||||
// noop
|
||||
|
|
|
|||
Loading…
Reference in a new issue