Adjust namespace and print a message when the job was skipped

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/27217/head
Joas Schilling 3 years ago
parent 9cd9f4b4bc
commit 0a812a1c09
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA

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