summaryrefslogtreecommitdiffstats
path: root/core/Command/Background
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-06-08 10:06:24 +0200
committerJoas Schilling <coding@schilljs.com>2021-10-14 09:57:16 +0200
commit0a812a1c0980d3ca65106875c59e4f0aff6a79a8 (patch)
treee2a65a06b5ed04b251d1b60c4d1b229b6dee1fba /core/Command/Background
parent9cd9f4b4bc87133cf446746295e9730c244b3a49 (diff)
downloadnextcloud-server-0a812a1c0980d3ca65106875c59e4f0aff6a79a8.tar.gz
nextcloud-server-0a812a1c0980d3ca65106875c59e4f0aff6a79a8.zip
Adjust namespace and print a message when the job was skipped
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core/Command/Background')
-rw-r--r--core/Command/Background/Job.php19
1 files changed, 14 insertions, 5 deletions
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('<comment>Forcing execution of the job</comment>');
+ $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('<info>Job executed!</info>');
$output->writeln('');
if ($job instanceof \OC\BackgroundJob\TimedJob || $job instanceof \OCP\BackgroundJob\TimedJob) {
$this->printJobInfo($jobId, $job, $output);
}
+ } else {
+ $output->writeln('<comment>Job was not executed because it is not due</comment>');
+ $output->writeln('Specify the <question>--force-execute</question> option to run it anyway');
}
return 0;