Browse Source

Adjust namespace and print a message when the job was skipped

Signed-off-by: Joas Schilling <coding@schilljs.com>
tags/v23.0.0beta1
Joas Schilling 3 years ago
parent
commit
0a812a1c09
No account linked to committer's email address
1 changed files with 14 additions and 5 deletions
  1. 14
    5
      core/Command/Background/Job.php

+ 14
- 5
core/Command/Background/Job.php View File

@@ -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;

Loading…
Cancel
Save