aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/TaskProcessing
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2024-07-03 16:08:13 +0200
committerMarcel Klehr <mklehr@gmx.net>2024-07-04 10:02:36 +0200
commit1b2c8d50303f3ce14a3e6f6fdf51c29ef78cbee0 (patch)
treed740fd70529bba2b4da3fa0074089e75b44451bf /lib/private/TaskProcessing
parent0116a631c63013e22c6ba9a182ff722607bb0295 (diff)
downloadnextcloud-server-1b2c8d50303f3ce14a3e6f6fdf51c29ef78cbee0.tar.gz
nextcloud-server-1b2c8d50303f3ce14a3e6f6fdf51c29ef78cbee0.zip
fix(TaskProcessing): Set task status to running when processing via ISynchronousProvider
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Diffstat (limited to 'lib/private/TaskProcessing')
-rw-r--r--lib/private/TaskProcessing/Manager.php11
-rw-r--r--lib/private/TaskProcessing/SynchronousBackgroundJob.php2
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/private/TaskProcessing/Manager.php b/lib/private/TaskProcessing/Manager.php
index 664805c57c8..74cc38d0949 100644
--- a/lib/private/TaskProcessing/Manager.php
+++ b/lib/private/TaskProcessing/Manager.php
@@ -15,6 +15,7 @@ use OC\TaskProcessing\Db\TaskMapper;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\BackgroundJob\IJobList;
+use OCP\DB\Exception;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\AppData\IAppDataFactory;
use OCP\Files\File;
@@ -870,4 +871,14 @@ class Manager implements IManager {
$task->setStatus(Task::STATUS_RUNNING);
return true;
}
+
+ /**
+ * @throws \JsonException
+ * @throws Exception
+ */
+ public function setTaskStatus(Task $task, int $status): void {
+ $task->setStatus($status);
+ $taskEntity = \OC\TaskProcessing\Db\Task::fromPublicTask($task);
+ $this->taskMapper->update($taskEntity);
+ }
}
diff --git a/lib/private/TaskProcessing/SynchronousBackgroundJob.php b/lib/private/TaskProcessing/SynchronousBackgroundJob.php
index 6109dd3f962..7f1ab623190 100644
--- a/lib/private/TaskProcessing/SynchronousBackgroundJob.php
+++ b/lib/private/TaskProcessing/SynchronousBackgroundJob.php
@@ -18,6 +18,7 @@ use OCP\TaskProcessing\Exception\ProcessingException;
use OCP\TaskProcessing\Exception\ValidationException;
use OCP\TaskProcessing\IManager;
use OCP\TaskProcessing\ISynchronousProvider;
+use OCP\TaskProcessing\Task;
use Psr\Log\LoggerInterface;
class SynchronousBackgroundJob extends QueuedJob {
@@ -61,6 +62,7 @@ class SynchronousBackgroundJob extends QueuedJob {
return;
}
try {
+ $this->taskProcessingManager->setTaskStatus($task, Task::STATUS_RUNNING);
$output = $provider->process($task->getUserId(), $input, fn (float $progress) => $this->taskProcessingManager->setTaskProgress($task->getId(), $progress));
} catch (ProcessingException $e) {
$this->logger->warning('Failed to process a TaskProcessing task with synchronous provider ' . $provider->getId(), ['exception' => $e]);