2018-10-09 06:36:43 -04:00
|
|
|
<?php
|
2019-12-03 13:57:53 -05:00
|
|
|
|
2018-10-09 06:36:43 -04:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2018-10-09 06:36:43 -04:00
|
|
|
*/
|
|
|
|
|
namespace OCP\BackgroundJob;
|
|
|
|
|
|
|
|
|
|
use OCP\ILogger;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Simple base class for a one time background job
|
|
|
|
|
*
|
|
|
|
|
* @since 15.0.0
|
|
|
|
|
*/
|
|
|
|
|
abstract class QueuedJob extends Job {
|
|
|
|
|
/**
|
2022-06-28 06:09:08 -04:00
|
|
|
* Run the job, then remove it from the joblist
|
2018-10-09 06:36:43 -04:00
|
|
|
*
|
|
|
|
|
* @param IJobList $jobList
|
|
|
|
|
* @param ILogger|null $logger
|
|
|
|
|
*
|
|
|
|
|
* @since 15.0.0
|
2024-09-18 17:51:06 -04:00
|
|
|
* @deprecated 25.0.0 Use start() instead. This method will be removed
|
2022-06-28 06:09:08 -04:00
|
|
|
* with the ILogger interface
|
2018-10-09 06:36:43 -04:00
|
|
|
*/
|
2024-03-28 11:13:19 -04:00
|
|
|
final public function execute($jobList, ?ILogger $logger = null) {
|
2022-06-28 06:09:08 -04:00
|
|
|
$this->start($jobList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Run the job, then remove it from the joblist
|
|
|
|
|
*
|
2022-06-28 06:55:26 -04:00
|
|
|
* @since 25.0.0
|
2022-06-28 06:09:08 -04:00
|
|
|
*/
|
|
|
|
|
final public function start(IJobList $jobList): void {
|
2024-05-30 09:07:26 -04:00
|
|
|
if ($this->id) {
|
|
|
|
|
$jobList->removeById($this->id);
|
|
|
|
|
} else {
|
|
|
|
|
$jobList->remove($this, $this->argument);
|
|
|
|
|
}
|
2022-06-28 06:09:08 -04:00
|
|
|
parent::start($jobList);
|
2018-10-09 06:36:43 -04:00
|
|
|
}
|
|
|
|
|
}
|