diff options
author | Marcel Klehr <mklehr@gmx.net> | 2024-07-04 12:53:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-04 12:53:54 +0200 |
commit | 03d71e859cc28adcb774f60f4955b7ce0b41f716 (patch) | |
tree | 607b3b4ce464c006873281745eb81f585e03e8f2 /lib/private/TaskProcessing | |
parent | 8cb0f1a3ae62790152795b66e57a6e9dd67f5996 (diff) | |
parent | 1b2c8d50303f3ce14a3e6f6fdf51c29ef78cbee0 (diff) | |
download | nextcloud-server-03d71e859cc28adcb774f60f4955b7ce0b41f716.tar.gz nextcloud-server-03d71e859cc28adcb774f60f4955b7ce0b41f716.zip |
Merge pull request #46286 from nextcloud/fix/tp/sync-bg-job-status
fix(TaskProcessing): Set task status to running when processing via ISynchronousProvider
Diffstat (limited to 'lib/private/TaskProcessing')
-rw-r--r-- | lib/private/TaskProcessing/Manager.php | 11 | ||||
-rw-r--r-- | lib/private/TaskProcessing/SynchronousBackgroundJob.php | 2 |
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]); |