mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Adjust namespace and print a message when the job was skipped
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
9cd9f4b4bc
commit
0a812a1c09
1 changed files with 14 additions and 5 deletions
|
|
@ -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…
Reference in a new issue