summaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorCôme Chilliet <91878298+come-nc@users.noreply.github.com>2022-12-06 12:14:43 +0100
committerGitHub <noreply@github.com>2022-12-06 12:14:43 +0100
commit1821712615cc4adc4a600ad8a86c4d68764bd3a6 (patch)
tree15fdb1f2754ac79fb779ad94d7117c9272e9df78 /apps/files
parent48358bb78f5955e982bcd07e7db252ad0ae43819 (diff)
parent72c7fad1c4997f7dd386f2476a084dcbbcc665a9 (diff)
downloadnextcloud-server-1821712615cc4adc4a600ad8a86c4d68764bd3a6.tar.gz
nextcloud-server-1821712615cc4adc4a600ad8a86c4d68764bd3a6.zip
Merge pull request #35596 from nextcloud/fix/move-to-ocp-timedjob
Use TimedJob from OCP instead of OC
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/lib/BackgroundJob/CleanupDirectEditingTokens.php15
-rw-r--r--apps/files/lib/BackgroundJob/CleanupFileLocks.php8
-rw-r--r--apps/files/lib/BackgroundJob/DeleteOrphanedItems.php6
-rw-r--r--apps/files/tests/BackgroundJob/DeleteOrphanedItemsJobTest.php13
4 files changed, 26 insertions, 16 deletions
diff --git a/apps/files/lib/BackgroundJob/CleanupDirectEditingTokens.php b/apps/files/lib/BackgroundJob/CleanupDirectEditingTokens.php
index 16f76a76dd8..a9b5b1446b2 100644
--- a/apps/files/lib/BackgroundJob/CleanupDirectEditingTokens.php
+++ b/apps/files/lib/BackgroundJob/CleanupDirectEditingTokens.php
@@ -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;
}
diff --git a/apps/files/lib/BackgroundJob/CleanupFileLocks.php b/apps/files/lib/BackgroundJob/CleanupFileLocks.php
index f22b8edcd9b..e0ad72eaaf0 100644
--- a/apps/files/lib/BackgroundJob/CleanupFileLocks.php
+++ b/apps/files/lib/BackgroundJob/CleanupFileLocks.php
@@ -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;
}
diff --git a/apps/files/lib/BackgroundJob/DeleteOrphanedItems.php b/apps/files/lib/BackgroundJob/DeleteOrphanedItems.php
index 720785f5727..669c2a4cde6 100644
--- a/apps/files/lib/BackgroundJob/DeleteOrphanedItems.php
+++ b/apps/files/lib/BackgroundJob/DeleteOrphanedItems.php
@@ -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();
diff --git a/apps/files/tests/BackgroundJob/DeleteOrphanedItemsJobTest.php b/apps/files/tests/BackgroundJob/DeleteOrphanedItemsJobTest.php
index 75318b1802f..f7562345d8a 100644
--- a/apps/files/tests/BackgroundJob/DeleteOrphanedItemsJobTest.php
+++ b/apps/files/tests/BackgroundJob/DeleteOrphanedItemsJobTest.php
@@ -24,6 +24,7 @@
namespace OCA\Files\Tests\BackgroundJob;
use OCA\Files\BackgroundJob\DeleteOrphanedItems;
+use OCP\AppFramework\Utility\ITimeFactory;
use OCP\DB\QueryBuilder\IQueryBuilder;
/**
@@ -34,13 +35,15 @@ use OCP\DB\QueryBuilder\IQueryBuilder;
* @package Test\BackgroundJob
*/
class DeleteOrphanedItemsJobTest extends \Test\TestCase {
-
/** @var \OCP\IDBConnection */
protected $connection;
+ protected ITimeFactory $timeFactory;
+
protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
+ $this->timeFactory = $this->createMock(ITimeFactory::class);
}
protected function cleanMapping($table) {
@@ -95,7 +98,7 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase {
$mapping = $this->getMappings('systemtag_object_mapping');
$this->assertCount(2, $mapping);
- $job = new DeleteOrphanedItems();
+ $job = new DeleteOrphanedItems($this->timeFactory);
$this->invokePrivate($job, 'cleanSystemTags');
$mapping = $this->getMappings('systemtag_object_mapping');
@@ -144,7 +147,7 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase {
$mapping = $this->getMappings('vcategory_to_object');
$this->assertCount(2, $mapping);
- $job = new DeleteOrphanedItems();
+ $job = new DeleteOrphanedItems($this->timeFactory);
$this->invokePrivate($job, 'cleanUserTags');
$mapping = $this->getMappings('vcategory_to_object');
@@ -195,7 +198,7 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase {
$mapping = $this->getMappings('comments');
$this->assertCount(2, $mapping);
- $job = new DeleteOrphanedItems();
+ $job = new DeleteOrphanedItems($this->timeFactory);
$this->invokePrivate($job, 'cleanComments');
$mapping = $this->getMappings('comments');
@@ -244,7 +247,7 @@ class DeleteOrphanedItemsJobTest extends \Test\TestCase {
$mapping = $this->getMappings('comments_read_markers');
$this->assertCount(2, $mapping);
- $job = new DeleteOrphanedItems();
+ $job = new DeleteOrphanedItems($this->timeFactory);
$this->invokePrivate($job, 'cleanCommentMarkers');
$mapping = $this->getMappings('comments_read_markers');