diff options
author | Marcel Klehr <mklehr@gmx.net> | 2023-10-20 12:17:17 +0200 |
---|---|---|
committer | Marcel Klehr <mklehr@gmx.net> | 2023-10-20 12:17:17 +0200 |
commit | 8968573d9fa0b9abac1dd5c7684dd94258a080cf (patch) | |
tree | 77c83cb8293a72e4b8b4f77dfcb84fe377be7703 /core/Controller/TextToImageApiController.php | |
parent | 92cc171a613059f0c15df9bcf26fdf54ef412683 (diff) | |
download | nextcloud-server-8968573d9fa0b9abac1dd5c7684dd94258a080cf.tar.gz nextcloud-server-8968573d9fa0b9abac1dd5c7684dd94258a080cf.zip |
enh(TextToImage): Add getExpectedRuntime to IProvider and run tasks during request lifetime if possible
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Diffstat (limited to 'core/Controller/TextToImageApiController.php')
-rw-r--r-- | core/Controller/TextToImageApiController.php | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/core/Controller/TextToImageApiController.php b/core/Controller/TextToImageApiController.php index 402d2983732..c7878d7cdc3 100644 --- a/core/Controller/TextToImageApiController.php +++ b/core/Controller/TextToImageApiController.php @@ -36,6 +36,7 @@ use OCP\AppFramework\Http\Attribute\PublicPage; use OCP\AppFramework\Http\Attribute\UserRateLimit; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\FileDisplayResponse; +use OCP\DB\Exception; use OCP\Files\NotFoundException; use OCP\IL10N; use OCP\IRequest; @@ -91,7 +92,11 @@ class TextToImageApiController extends \OCP\AppFramework\OCSController { public function schedule(string $input, string $appId, string $identifier = ''): DataResponse { $task = new Task($input, $appId, $this->userId, $identifier); try { - $this->textToImageManager->scheduleTask($task); + try { + $this->textToImageManager->runOrScheduleTask($task); + } catch (\RuntimeException) { + // noop + } $json = $task->jsonSerialize(); @@ -100,6 +105,8 @@ class TextToImageApiController extends \OCP\AppFramework\OCSController { ]); } catch (PreConditionNotMetException) { return new DataResponse(['message' => $this->l->t('No text to image provider is available')], Http::STATUS_PRECONDITION_FAILED); + } catch (Exception) { + return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR); } } |