aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Veyssier <julien-nc@posteo.net>2024-10-01 23:42:08 +0200
committerGitHub <noreply@github.com>2024-10-01 23:42:08 +0200
commit0e1cb723e807fb0a6445f47597677fd2645ea8eb (patch)
treeb315507b95331525c61d5149062160321c43c2d8
parent1c1f48830ad1a70628d14fbed7a7d76065818a56 (diff)
parent14cf5b03caa985474b1c8edc7fef2ce1627528d7 (diff)
downloadnextcloud-server-0e1cb723e807fb0a6445f47597677fd2645ea8eb.tar.gz
nextcloud-server-0e1cb723e807fb0a6445f47597677fd2645ea8eb.zip
Merge pull request #48496 from nextcloud/enh/noid/taskprocessing-commands-task-errors
[taskprocessing] Add new command to get a task from a task ID
-rw-r--r--core/Command/TaskProcessing/GetCommand.php41
-rw-r--r--core/Command/TaskProcessing/ListCommand.php6
-rw-r--r--core/register_command.php1
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_static.php1
5 files changed, 49 insertions, 1 deletions
diff --git a/core/Command/TaskProcessing/GetCommand.php b/core/Command/TaskProcessing/GetCommand.php
new file mode 100644
index 00000000000..a61ddbe1621
--- /dev/null
+++ b/core/Command/TaskProcessing/GetCommand.php
@@ -0,0 +1,41 @@
+<?php
+/**
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OC\Core\Command\TaskProcessing;
+
+use OC\Core\Command\Base;
+use OCP\TaskProcessing\IManager;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class GetCommand extends Base {
+ public function __construct(
+ protected IManager $taskProcessingManager,
+ ) {
+ parent::__construct();
+ }
+
+ protected function configure() {
+ $this
+ ->setName('taskprocessing:task:get')
+ ->setDescription('Display all information for a specific task')
+ ->addArgument(
+ 'task-id',
+ InputArgument::REQUIRED,
+ 'ID of the task to display'
+ );
+ parent::configure();
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output): int {
+ $taskId = (int)$input->getArgument('task-id');
+ $task = $this->taskProcessingManager->getTask($taskId);
+ $jsonTask = $task->jsonSerialize();
+ $jsonTask['error_message'] = $task->getErrorMessage();
+ $this->writeArrayInOutputFormat($input, $output, $jsonTask);
+ return 0;
+ }
+}
diff --git a/core/Command/TaskProcessing/ListCommand.php b/core/Command/TaskProcessing/ListCommand.php
index 46f32e0bc53..f4ea76729d9 100644
--- a/core/Command/TaskProcessing/ListCommand.php
+++ b/core/Command/TaskProcessing/ListCommand.php
@@ -83,7 +83,11 @@ class ListCommand extends Base {
$endedBefore = $input->getOption('endedBefore');
$tasks = $this->taskProcessingManager->getTasks($userIdFilter, $type, $appId, $customId, $status, $scheduledAfter, $endedBefore);
- $arrayTasks = array_map(fn (Task $task): array => $task->jsonSerialize(), $tasks);
+ $arrayTasks = array_map(static function (Task $task) {
+ $jsonTask = $task->jsonSerialize();
+ $jsonTask['error_message'] = $task->getErrorMessage();
+ return $jsonTask;
+ }, $tasks);
$this->writeArrayInOutputFormat($input, $output, $arrayTasks);
return 0;
diff --git a/core/register_command.php b/core/register_command.php
index 5857c227fea..faa2c3021a7 100644
--- a/core/register_command.php
+++ b/core/register_command.php
@@ -145,6 +145,7 @@ if ($config->getSystemValueBool('installed', false)) {
$application->add(Server::get(Command\SetupChecks::class));
$application->add(Server::get(Command\FilesMetadata\Get::class));
+ $application->add(Server::get(Command\TaskProcessing\GetCommand::class));
$application->add(Server::get(Command\TaskProcessing\ListCommand::class));
$application->add(Server::get(Command\TaskProcessing\Statistics::class));
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 8f1ba58c3cd..603e0a1455c 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -1228,6 +1228,7 @@ return array(
'OC\\Core\\Command\\SystemTag\\Delete' => $baseDir . '/core/Command/SystemTag/Delete.php',
'OC\\Core\\Command\\SystemTag\\Edit' => $baseDir . '/core/Command/SystemTag/Edit.php',
'OC\\Core\\Command\\SystemTag\\ListCommand' => $baseDir . '/core/Command/SystemTag/ListCommand.php',
+ 'OC\\Core\\Command\\TaskProcessing\\GetCommand' => $baseDir . '/core/Command/TaskProcessing/GetCommand.php',
'OC\\Core\\Command\\TaskProcessing\\ListCommand' => $baseDir . '/core/Command/TaskProcessing/ListCommand.php',
'OC\\Core\\Command\\TaskProcessing\\Statistics' => $baseDir . '/core/Command/TaskProcessing/Statistics.php',
'OC\\Core\\Command\\TwoFactorAuth\\Base' => $baseDir . '/core/Command/TwoFactorAuth/Base.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index bd6aab1843b..17bbd9738dd 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -1261,6 +1261,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\Core\\Command\\SystemTag\\Delete' => __DIR__ . '/../../..' . '/core/Command/SystemTag/Delete.php',
'OC\\Core\\Command\\SystemTag\\Edit' => __DIR__ . '/../../..' . '/core/Command/SystemTag/Edit.php',
'OC\\Core\\Command\\SystemTag\\ListCommand' => __DIR__ . '/../../..' . '/core/Command/SystemTag/ListCommand.php',
+ 'OC\\Core\\Command\\TaskProcessing\\GetCommand' => __DIR__ . '/../../..' . '/core/Command/TaskProcessing/GetCommand.php',
'OC\\Core\\Command\\TaskProcessing\\ListCommand' => __DIR__ . '/../../..' . '/core/Command/TaskProcessing/ListCommand.php',
'OC\\Core\\Command\\TaskProcessing\\Statistics' => __DIR__ . '/../../..' . '/core/Command/TaskProcessing/Statistics.php',
'OC\\Core\\Command\\TwoFactorAuth\\Base' => __DIR__ . '/../../..' . '/core/Command/TwoFactorAuth/Base.php',