Skip to content

Commit

Permalink
Refactor OC\Server::getJobList
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Summers <[email protected]>
  • Loading branch information
summersab committed Aug 30, 2023
1 parent 9d1547f commit 3b53d0c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
6 changes: 4 additions & 2 deletions core/register_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

use OCP\BackgroundJob\IJobList;
use Psr\Log\LoggerInterface;

$application->add(new \Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand());
Expand Down Expand Up @@ -89,8 +91,8 @@
$application->add(new OC\Core\Command\Background\Cron(\OC::$server->getConfig()));
$application->add(new OC\Core\Command\Background\WebCron(\OC::$server->getConfig()));
$application->add(new OC\Core\Command\Background\Ajax(\OC::$server->getConfig()));
$application->add(new OC\Core\Command\Background\Job(\OC::$server->getJobList(), \OC::$server->getLogger()));
$application->add(new OC\Core\Command\Background\ListCommand(\OC::$server->getJobList()));
$application->add(new OC\Core\Command\Background\Job(\OC::$server->get(IJobList::class), \OC::$server->getLogger()));
$application->add(new OC\Core\Command\Background\ListCommand(\OC::$server->get(IJobList::class)));

$application->add(\OC::$server->query(\OC\Core\Command\Broadcast\Test::class));

Expand Down
6 changes: 4 additions & 2 deletions cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
*/
require_once __DIR__ . '/lib/versioncheck.php';

use OCP\BackgroundJob\IJobList;

try {
require_once __DIR__ . '/lib/base.php';

Expand Down Expand Up @@ -134,7 +136,7 @@
}

// Work
$jobList = \OC::$server->getJobList();
$jobList = \OC::$server->get(IJobList::class);

// We only ask for jobs for 14 minutes, because after 5 minutes the next
// system cron task should spawn and we want to have at most three
Expand Down Expand Up @@ -170,7 +172,7 @@
OC_JSON::error(['data' => ['message' => 'Backgroundjobs are using system cron!']]);
} else {
// Work and success :-)
$jobList = \OC::$server->getJobList();
$jobList = \OC::$server->get(IJobList::class);
$job = $jobList->getNext();
if ($job != null) {
$logger->debug('WebCron call has selected job with ID ' . strval($job->getId()), ['app' => 'cron']);
Expand Down
13 changes: 7 additions & 6 deletions lib/private/Repair.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use OC\Repair\CleanUpAbandonedApps;
use OCP\AppFramework\QueryException;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\Collaboration\Resources\IManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Migration\IOutput;
Expand Down Expand Up @@ -180,24 +181,24 @@ public static function getRepairSteps(): array {
new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
new MoveUpdaterStepFile(\OC::$server->getConfig()),
new MoveAvatars(
\OC::$server->getJobList(),
\OC::$server->get(IJobList::class),
\OC::$server->getConfig()
),
new CleanPreviews(
\OC::$server->getJobList(),
\OC::$server->get(IJobList::class),
\OC::$server->getUserManager(),
\OC::$server->getConfig()
),
new MigrateOauthTables(\OC::$server->get(Connection::class)),
new FixMountStorages(\OC::$server->getDatabaseConnection()),
new UpdateLanguageCodes(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()),
new AddLogRotateJob(\OC::$server->getJobList()),
new AddLogRotateJob(\OC::$server->get(IJobList::class)),
new ClearFrontendCaches(\OC::$server->getMemCacheFactory(), \OCP\Server::get(JSCombiner::class)),
\OCP\Server::get(ClearGeneratedAvatarCache::class),
new AddPreviewBackgroundCleanupJob(\OC::$server->getJobList()),
new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()),
new AddPreviewBackgroundCleanupJob(\OC::$server->get(IJobList::class)),
new AddCleanupUpdaterBackupsJob(\OC::$server->get(IJobList::class)),
new CleanupCardDAVPhotoCache(\OC::$server->getConfig(), \OC::$server->getAppDataDir('dav-photocache'), \OC::$server->get(LoggerInterface::class)),
new AddClenupLoginFlowV2BackgroundJob(\OC::$server->getJobList()),
new AddClenupLoginFlowV2BackgroundJob(\OC::$server->get(IJobList::class)),
new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OCP\Server::get(ITimeFactory::class)),
new ClearCollectionsAccessCache(\OC::$server->getConfig(), \OCP\Server::get(IManager::class)),
\OCP\Server::get(ResetGeneratedAvatarFlag::class),
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
use OC\Log\Rotate;
use OC\Preview\BackgroundCleanupJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\Defaults;
use OCP\IGroup;
use OCP\IL10N;
Expand Down Expand Up @@ -450,7 +451,7 @@ public function install($options) {
}

public static function installBackgroundJobs() {
$jobList = \OC::$server->getJobList();
$jobList = \OC::$server->get(IJobList::class);
$jobList->add(TokenCleanupJob::class);
$jobList->add(Rotate::class);
$jobList->add(BackgroundCleanupJob::class);
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Share20/ProviderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use OCA\ShareByMail\Settings\SettingsManager;
use OCA\ShareByMail\ShareByMailProvider;
use OCA\Talk\Share\RoomShareProvider;
use OCP\BackgroundJob\IJobList;
use OCP\Defaults;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IServerContainer;
Expand Down Expand Up @@ -139,7 +140,7 @@ protected function federatedShareProvider() {
$addressHandler,
$this->serverContainer->getHTTPClientService(),
$this->serverContainer->query(\OCP\OCS\IDiscoveryService::class),
$this->serverContainer->getJobList(),
$this->serverContainer->get(IJobList::class),
\OC::$server->getCloudFederationProviderManager(),
\OC::$server->getCloudFederationFactory(),
$this->serverContainer->query(IEventDispatcher::class),
Expand Down
5 changes: 3 additions & 2 deletions lib/private/legacy/OC_App.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
use OCP\App\IAppManager;
use OCP\App\ManagerEvent;
use OCP\Authentication\IAlternativeLogin;
use OCP\BackgroundJob\IJobList;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\ILogger;
use OC\AppFramework\Bootstrap\Coordinator;
Expand Down Expand Up @@ -838,7 +839,7 @@ public static function executeRepairSteps(string $appId, array $steps) {
}

public static function setupBackgroundJobs(array $jobs) {
$queue = \OC::$server->getJobList();
$queue = \OC::$server->get(IJobList::class);
foreach ($jobs as $job) {
$queue->add($job);
}
Expand All @@ -849,7 +850,7 @@ public static function setupBackgroundJobs(array $jobs) {
* @param string[] $steps
*/
private static function setupLiveMigrations(string $appId, array $steps) {
$queue = \OC::$server->getJobList();
$queue = \OC::$server->get(IJobList::class);
foreach ($steps as $step) {
$queue->add('OC\Migration\BackgroundRepair', [
'app' => $appId,
Expand Down

0 comments on commit 3b53d0c

Please sign in to comment.