summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2022-02-22 11:24:38 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2022-02-22 13:55:06 +0100
commitc01eb0775648bd54e9cd4904499a30f448554968 (patch)
treec06b619b4af515e48db263af4d82cee18473ba31 /apps/dav/lib
parenta6bc871c96d071ef54d9fd3b547df606fa9d19ca (diff)
downloadnextcloud-server-c01eb0775648bd54e9cd4904499a30f448554968.tar.gz
nextcloud-server-c01eb0775648bd54e9cd4904499a30f448554968.zip
Mark DAV background jobs as time sensitive/insensitive
* As a bonus they are now all using OCP base classes * Strict typing is now enforced Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/BackgroundJob/CalendarRetentionJob.php1
-rw-r--r--apps/dav/lib/BackgroundJob/CleanupDirectLinksJob.php15
-rw-r--r--apps/dav/lib/BackgroundJob/CleanupInvitationTokenJob.php15
-rw-r--r--apps/dav/lib/BackgroundJob/EventReminderJob.php23
-rw-r--r--apps/dav/lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php17
-rw-r--r--apps/dav/lib/BackgroundJob/RegisterRegenerateBirthdayCalendars.php3
-rw-r--r--apps/dav/lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php10
7 files changed, 47 insertions, 37 deletions
diff --git a/apps/dav/lib/BackgroundJob/CalendarRetentionJob.php b/apps/dav/lib/BackgroundJob/CalendarRetentionJob.php
index 6be6d7c3cd1..b57ed07d5c2 100644
--- a/apps/dav/lib/BackgroundJob/CalendarRetentionJob.php
+++ b/apps/dav/lib/BackgroundJob/CalendarRetentionJob.php
@@ -40,6 +40,7 @@ class CalendarRetentionJob extends TimedJob {
// Run four times a day
$this->setInterval(6 * 60 * 60);
+ $this->setTimeSensitivity(self::TIME_SENSITIVE);
}
protected function run($argument): void {
diff --git a/apps/dav/lib/BackgroundJob/CleanupDirectLinksJob.php b/apps/dav/lib/BackgroundJob/CleanupDirectLinksJob.php
index 6c10a05f9a5..073fc53e07a 100644
--- a/apps/dav/lib/BackgroundJob/CleanupDirectLinksJob.php
+++ b/apps/dav/lib/BackgroundJob/CleanupDirectLinksJob.php
@@ -26,26 +26,25 @@ declare(strict_types=1);
*/
namespace OCA\DAV\BackgroundJob;
-use OC\BackgroundJob\TimedJob;
use OCA\DAV\Db\DirectMapper;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\BackgroundJob\TimedJob;
class CleanupDirectLinksJob extends TimedJob {
- /** @var ITimeFactory */
- private $timeFactory;
-
/** @var DirectMapper */
private $mapper;
public function __construct(ITimeFactory $timeFactory, DirectMapper $mapper) {
- $this->setInterval(60 * 60 * 24);
-
- $this->timeFactory = $timeFactory;
+ parent::__construct($timeFactory);
$this->mapper = $mapper;
+
+ // Run once a day at off-peak time
+ $this->setInterval(24 * 60 * 60);
+ $this->setTimeSensitivity(self::TIME_INSENSITIVE);
}
protected function run($argument) {
// Delete all shares expired 24 hours ago
- $this->mapper->deleteExpired($this->timeFactory->getTime() - 60 * 60 * 24);
+ $this->mapper->deleteExpired($this->time->getTime() - 60 * 60 * 24);
}
}
diff --git a/apps/dav/lib/BackgroundJob/CleanupInvitationTokenJob.php b/apps/dav/lib/BackgroundJob/CleanupInvitationTokenJob.php
index 9621b5d9499..6339e721c93 100644
--- a/apps/dav/lib/BackgroundJob/CleanupInvitationTokenJob.php
+++ b/apps/dav/lib/BackgroundJob/CleanupInvitationTokenJob.php
@@ -26,8 +26,8 @@ declare(strict_types=1);
*/
namespace OCA\DAV\BackgroundJob;
-use OC\BackgroundJob\TimedJob;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\BackgroundJob\TimedJob;
use OCP\IDBConnection;
class CleanupInvitationTokenJob extends TimedJob {
@@ -35,21 +35,20 @@ class CleanupInvitationTokenJob extends TimedJob {
/** @var IDBConnection */
private $db;
- /** @var ITimeFactory */
- private $timeFactory;
-
- public function __construct(IDBConnection $db, ITimeFactory $timeFactory) {
+ public function __construct(IDBConnection $db, ITimeFactory $time) {
+ parent::__construct($time);
$this->db = $db;
- $this->timeFactory = $timeFactory;
- $this->setInterval(60 * 60 * 24);
+ // Run once a day at off-peak time
+ $this->setInterval(24 * 60 * 60);
+ $this->setTimeSensitivity(self::TIME_INSENSITIVE);
}
public function run($argument) {
$query = $this->db->getQueryBuilder();
$query->delete('calendar_invitations')
->where($query->expr()->lt('expiration',
- $query->createNamedParameter($this->timeFactory->getTime())))
+ $query->createNamedParameter($this->time->getTime())))
->execute();
}
}
diff --git a/apps/dav/lib/BackgroundJob/EventReminderJob.php b/apps/dav/lib/BackgroundJob/EventReminderJob.php
index b67a5d970bb..ab7dadd8c0b 100644
--- a/apps/dav/lib/BackgroundJob/EventReminderJob.php
+++ b/apps/dav/lib/BackgroundJob/EventReminderJob.php
@@ -1,4 +1,7 @@
<?php
+
+declare(strict_types=1);
+
/**
* @copyright Copyright (c) 2016 Thomas Citharel <nextcloud@tcit.fr>
*
@@ -23,8 +26,9 @@
*/
namespace OCA\DAV\BackgroundJob;
-use OC\BackgroundJob\TimedJob;
use OCA\DAV\CalDAV\Reminder\ReminderService;
+use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\BackgroundJob\TimedJob;
use OCP\IConfig;
class EventReminderJob extends TimedJob {
@@ -35,17 +39,16 @@ class EventReminderJob extends TimedJob {
/** @var IConfig */
private $config;
- /**
- * EventReminderJob constructor.
- *
- * @param ReminderService $reminderService
- * @param IConfig $config
- */
- public function __construct(ReminderService $reminderService, IConfig $config) {
+ public function __construct(ITimeFactory $time,
+ ReminderService $reminderService,
+ IConfig $config) {
+ parent::__construct($time);
$this->reminderService = $reminderService;
$this->config = $config;
- /** Run every 5 minutes */
- $this->setInterval(5);
+
+ // Run every 5 minutes
+ $this->setInterval(5 * 60);
+ $this->setTimeSensitivity(self::TIME_SENSITIVE);
}
/**
diff --git a/apps/dav/lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php b/apps/dav/lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php
index 2fdb7617937..a338a172d66 100644
--- a/apps/dav/lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php
+++ b/apps/dav/lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php
@@ -1,4 +1,7 @@
<?php
+
+declare(strict_types=1);
+
/**
* @copyright 2017 Georg Ehrke <oc.list@georgehrke.com>
*
@@ -22,8 +25,9 @@
*/
namespace OCA\DAV\BackgroundJob;
-use OC\BackgroundJob\QueuedJob;
use OCA\DAV\CalDAV\BirthdayService;
+use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\BackgroundJob\QueuedJob;
use OCP\IConfig;
class GenerateBirthdayCalendarBackgroundJob extends QueuedJob {
@@ -34,14 +38,11 @@ class GenerateBirthdayCalendarBackgroundJob extends QueuedJob {
/** @var IConfig */
private $config;
- /**
- * GenerateAllBirthdayCalendarsBackgroundJob constructor.
- *
- * @param BirthdayService $birthdayService
- * @param IConfig $config
- */
- public function __construct(BirthdayService $birthdayService,
+ public function __construct(ITimeFactory $time,
+ BirthdayService $birthdayService,
IConfig $config) {
+ parent::__construct($time);
+
$this->birthdayService = $birthdayService;
$this->config = $config;
}
diff --git a/apps/dav/lib/BackgroundJob/RegisterRegenerateBirthdayCalendars.php b/apps/dav/lib/BackgroundJob/RegisterRegenerateBirthdayCalendars.php
index 0813de7d1ad..85da81b3b91 100644
--- a/apps/dav/lib/BackgroundJob/RegisterRegenerateBirthdayCalendars.php
+++ b/apps/dav/lib/BackgroundJob/RegisterRegenerateBirthdayCalendars.php
@@ -1,4 +1,7 @@
<?php
+
+declare(strict_types=1);
+
/**
* @copyright 2019 Georg Ehrke <oc.list@georgehrke.com>
*
diff --git a/apps/dav/lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php b/apps/dav/lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php
index 9b3aeac5904..f7addd58248 100644
--- a/apps/dav/lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php
+++ b/apps/dav/lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php
@@ -28,8 +28,9 @@ declare(strict_types=1);
namespace OCA\DAV\BackgroundJob;
-use OC\BackgroundJob\TimedJob;
use OCA\DAV\CalDAV\CalDavBackend;
+use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\BackgroundJob\TimedJob;
use OCP\Calendar\BackendTemporarilyUnavailableException;
use OCP\Calendar\IMetadataProvider;
use OCP\Calendar\Resource\IBackend as IResourceBackend;
@@ -53,17 +54,20 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
/** @var CalDavBackend */
private $calDavBackend;
- public function __construct(IResourceManager $resourceManager,
+ public function __construct(ITimeFactory $time,
+ IResourceManager $resourceManager,
IRoomManager $roomManager,
IDBConnection $dbConnection,
CalDavBackend $calDavBackend) {
+ parent::__construct($time);
$this->resourceManager = $resourceManager;
$this->roomManager = $roomManager;
$this->dbConnection = $dbConnection;
$this->calDavBackend = $calDavBackend;
- // run once an hour
+ // Run once an hour
$this->setInterval(60 * 60);
+ $this->setTimeSensitivity(self::TIME_SENSITIVE);
}
/**