From 0a812a1c0980d3ca65106875c59e4f0aff6a79a8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 8 Jun 2021 10:06:24 +0200 Subject: Adjust namespace and print a message when the job was skipped Signed-off-by: Joas Schilling --- core/Command/Background/Job.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'core/Command') diff --git a/core/Command/Background/Job.php b/core/Command/Background/Job.php index 62f2ea823dd..fdac7ed5f27 100644 --- a/core/Command/Background/Job.php +++ b/core/Command/Background/Job.php @@ -49,7 +49,7 @@ class Job extends Command { protected function configure(): void { $this - ->setName('background:job') + ->setName('background-job:execute') ->setDescription('Execute a single background job manually') ->addArgument( 'job-id', @@ -75,22 +75,31 @@ class Job extends Command { } $this->printJobInfo($jobId, $job, $output); + $output->writeln(''); + $lastRun = $job->getLastRun(); if ($input->getOption('force-execute')) { - $output->writeln(''); + $lastRun = 0; $output->writeln('Forcing execution of the job'); + $output->writeln(''); $this->jobList->resetBackgroundJob($job); - $job = $this->jobList->getById($jobId); - $job->execute($this->jobList, $this->logger); - $this->jobList->setLastJob($job); + } + $job = $this->jobList->getById($jobId); + $job->execute($this->jobList, $this->logger); + $job = $this->jobList->getById($jobId); + + if ($lastRun !== $job->getLastRun()) { $output->writeln('Job executed!'); $output->writeln(''); if ($job instanceof \OC\BackgroundJob\TimedJob || $job instanceof \OCP\BackgroundJob\TimedJob) { $this->printJobInfo($jobId, $job, $output); } + } else { + $output->writeln('Job was not executed because it is not due'); + $output->writeln('Specify the --force-execute option to run it anyway'); } return 0; -- cgit v1.2.3