]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix LanguageModelManager#runTask: Insert task into db if it doesn't exist
authorMarcel Klehr <mklehr@gmx.net>
Fri, 30 Jun 2023 11:20:15 +0000 (13:20 +0200)
committerMarcel Klehr <mklehr@gmx.net>
Wed, 9 Aug 2023 08:01:25 +0000 (10:01 +0200)
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
(cherry picked from commit 1747068e518240edec22ff3c4f6946ac925918fe)

lib/private/LanguageModel/LanguageModelManager.php

index 9117b131578ab04158110aef7ba1e88479b984fd..e07762cf8cc9ae7e9900cb353a30d338b75da746 100644 (file)
@@ -120,8 +120,12 @@ class LanguageModelManager implements ILanguageModelManager {
                        }
                        try {
                                $task->setStatus(ILanguageModelTask::STATUS_RUNNING);
-                               $taskEntity = $this->taskMapper->update(Task::fromLanguageModelTask($task));
-                               $task->setId($taskEntity->getId());
+                               if ($task->getId() === null) {
+                                       $taskEntity = $this->taskMapper->insert(Task::fromLanguageModelTask($task));
+                                       $task->setId($taskEntity->getId());
+                               }else {
+                                       $this->taskMapper->update(Task::fromLanguageModelTask($task));
+                               }
                                $output = $task->visitProvider($provider);
                                $task->setOutput($output);
                                $task->setStatus(ILanguageModelTask::STATUS_SUCCESSFUL);