mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 14:23:17 -04:00
fix(TaskProcessing): Set task status to running when processing via ISynchronousProvider
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
parent
0116a631c6
commit
1b2c8d5030
3 changed files with 23 additions and 0 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
|
|
|||
|
|
@ -172,4 +172,14 @@ interface IManager {
|
|||
* @since 30.0.0
|
||||
*/
|
||||
public function lockTask(Task $task): bool;
|
||||
|
||||
/**
|
||||
* @param Task $task
|
||||
* @psalm-param Task::STATUS_* $status
|
||||
* @param int $status
|
||||
* @throws \JsonException
|
||||
* @throws Exception
|
||||
* @since 30.0.0
|
||||
*/
|
||||
public function setTaskStatus(Task $task, int $status): void;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue