Browse Source

Use TimedJob from OCP instead of OC

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
tags/v26.0.0beta1
Côme Chilliet 1 year ago
parent
commit
a0f6a6545b
No account linked to committer's email address

+ 7
- 3
apps/admin_audit/lib/BackgroundJobs/Rotate.php View File

@@ -27,7 +27,8 @@ declare(strict_types=1);
*/
namespace OCA\AdminAudit\BackgroundJobs;

use OC\BackgroundJob\TimedJob;
use OCP\BackgroundJob\TimedJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IConfig;
use OCP\Log\RotationTrait;

@@ -37,13 +38,16 @@ class Rotate extends TimedJob {
/** @var IConfig */
private $config;

public function __construct(IConfig $config) {
public function __construct(ITimeFactory $time,
IConfig $config) {
parent::__construct($time);

$this->config = $config;

$this->setInterval(60 * 60 * 3);
}

protected function run($argument) {
protected function run($argument): void {
$default = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log';
$this->filePath = $this->config->getAppValue('admin_audit', 'logfile', $default);


+ 9
- 6
apps/files/lib/BackgroundJob/CleanupDirectEditingTokens.php View File

@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2016 Julius Härtl <jus@bitgrid.net>
*
@@ -23,18 +26,18 @@
*/
namespace OCA\Files\BackgroundJob;

use OC\BackgroundJob\TimedJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCP\DirectEditing\IManager;

class CleanupDirectEditingTokens extends TimedJob {
private const INTERVAL_MINUTES = 15 * 60;

/**
* @var IManager
*/
private $manager;
private IManager $manager;

public function __construct(IManager $manager) {
public function __construct(ITimeFactory $time,
IManager $manager) {
parent::__construct($time);
$this->interval = self::INTERVAL_MINUTES;
$this->manager = $manager;
}

+ 5
- 3
apps/files/lib/BackgroundJob/CleanupFileLocks.php View File

@@ -23,14 +23,14 @@
*/
namespace OCA\Files\BackgroundJob;

use OC\BackgroundJob\TimedJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OC\Lock\DBLockingProvider;

/**
* Clean up all file locks that are expired for the DB file locking provider
*/
class CleanupFileLocks extends TimedJob {

/**
* Default interval in minutes
*
@@ -41,7 +41,9 @@ class CleanupFileLocks extends TimedJob {
/**
* sets the correct interval for this timed job
*/
public function __construct() {
public function __construct(ITimeFactory $time) {
parent::__construct($time);

$this->interval = $this->defaultIntervalMin * 60;
}


+ 4
- 2
apps/files/lib/BackgroundJob/DeleteOrphanedItems.php View File

@@ -24,7 +24,8 @@
*/
namespace OCA\Files\BackgroundJob;

use OC\BackgroundJob\TimedJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCP\DB\QueryBuilder\IQueryBuilder;

/**
@@ -49,7 +50,8 @@ class DeleteOrphanedItems extends TimedJob {
/**
* sets the correct interval for this timed job
*/
public function __construct() {
public function __construct(ITimeFactory $time) {
parent::__construct($time);
$this->interval = $this->defaultIntervalMin * 60;
$this->connection = \OC::$server->getDatabaseConnection();
$this->logger = \OC::$server->getLogger();

+ 5
- 2
apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php View File

@@ -26,7 +26,8 @@ declare(strict_types=1);
*/
namespace OCA\Files_Sharing\BackgroundJob;

use OC\BackgroundJob\TimedJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCP\IDBConnection;
use OCP\OCS\IDiscoveryService;

@@ -36,8 +37,10 @@ class FederatedSharesDiscoverJob extends TimedJob {
/** @var IDiscoveryService */
private $discoveryService;

public function __construct(IDBConnection $connection,
public function __construct(ITimeFactory $time,
IDBConnection $connection,
IDiscoveryService $discoveryService) {
parent::__construct($time);
$this->connection = $connection;
$this->discoveryService = $discoveryService;


+ 5
- 3
apps/files_sharing/lib/DeleteOrphanedSharesJob.php View File

@@ -24,13 +24,13 @@
*/
namespace OCA\Files_Sharing;

use OC\BackgroundJob\TimedJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;

/**
* Delete all share entries that have no matching entries in the file cache table.
*/
class DeleteOrphanedSharesJob extends TimedJob {

/**
* Default interval in minutes
*
@@ -41,7 +41,9 @@ class DeleteOrphanedSharesJob extends TimedJob {
/**
* sets the correct interval for this timed job
*/
public function __construct() {
public function __construct(ITimeFactory $time) {
parent::__construct($time);

$this->interval = $this->defaultIntervalMin * 60;
}


+ 5
- 2
apps/updatenotification/lib/Notification/BackgroundJob.php View File

@@ -26,10 +26,11 @@ declare(strict_types=1);
*/
namespace OCA\UpdateNotification\Notification;

use OC\BackgroundJob\TimedJob;
use OC\Installer;
use OC\Updater\VersionCheck;
use OCP\App\IAppManager;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\IGroup;
@@ -60,12 +61,14 @@ class BackgroundJob extends TimedJob {
/** @var string[] */
protected $users;

public function __construct(IConfig $config,
public function __construct(ITimeFactory $timeFactory,
IConfig $config,
IManager $notificationManager,
IGroupManager $groupManager,
IAppManager $appManager,
IClientService $client,
Installer $installer) {
parent::__construct($timeFactory);
// Run once a day
$this->setInterval(60 * 60 * 24);


+ 8
- 2
apps/user_ldap/lib/Jobs/CleanUp.php View File

@@ -25,7 +25,8 @@
*/
namespace OCA\User_LDAP\Jobs;

use OC\BackgroundJob\TimedJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCA\User_LDAP\Helper;
use OCA\User_LDAP\Mapping\UserMapping;
use OCA\User_LDAP\User\DeletedUsersIndex;
@@ -64,7 +65,12 @@ class CleanUp extends TimedJob {
/** @var DeletedUsersIndex */
protected $dui;

public function __construct(User_Proxy $userBackend, DeletedUsersIndex $dui) {
public function __construct(
ITimeFactory $timeFactory,
User_Proxy $userBackend,
DeletedUsersIndex $dui
) {
parent::__construct($timeFactory);
$minutes = \OC::$server->getConfig()->getSystemValue(
'ldapUserCleanupInterval', (string)$this->defaultIntervalMin);
$this->setInterval((int)$minutes * 60);

+ 4
- 2
apps/workflowengine/lib/BackgroundJobs/Rotate.php View File

@@ -23,14 +23,16 @@
*/
namespace OCA\WorkflowEngine\BackgroundJobs;

use OC\BackgroundJob\TimedJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCA\WorkflowEngine\AppInfo\Application;
use OCP\Log\RotationTrait;

class Rotate extends TimedJob {
use RotationTrait;

public function __construct() {
public function __construct(ITimeFactory $time) {
parent::__construct($time);
$this->setInterval(60 * 60 * 3);
}


+ 5
- 3
lib/private/Preview/BackgroundCleanupJob.php View File

@@ -25,8 +25,9 @@ declare(strict_types=1);
*/
namespace OC\Preview;

use OC\BackgroundJob\TimedJob;
use OC\Preview\Storage\Root;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Files\IMimeTypeLoader;
use OCP\Files\NotFoundException;
@@ -34,7 +35,6 @@ use OCP\Files\NotPermittedException;
use OCP\IDBConnection;

class BackgroundCleanupJob extends TimedJob {

/** @var IDBConnection */
private $connection;

@@ -47,10 +47,12 @@ class BackgroundCleanupJob extends TimedJob {
/** @var IMimeTypeLoader */
private $mimeTypeLoader;

public function __construct(IDBConnection $connection,
public function __construct(ITimeFactory $timeFactory,
IDBConnection $connection,
Root $previewFolder,
IMimeTypeLoader $mimeTypeLoader,
bool $isCLI) {
parent::__construct($timeFactory);
// Run at most once an hour
$this->setInterval(3600);


Loading…
Cancel
Save