]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(BackgroundJobs): Adjust intervals and time sensitivities
authorprovokateurin <kate@provokateurin.de>
Mon, 7 Oct 2024 15:36:55 +0000 (17:36 +0200)
committerprovokateurin <kate@provokateurin.de>
Tue, 8 Oct 2024 09:26:53 +0000 (11:26 +0200)
Signed-off-by: provokateurin <kate@provokateurin.de>
26 files changed:
apps/contactsinteraction/lib/BackgroundJob/CleanupJob.php
apps/dav/lib/BackgroundJob/UploadCleanup.php
apps/federation/lib/SyncJob.php
apps/files/lib/BackgroundJob/CleanupDirectEditingTokens.php
apps/files/lib/BackgroundJob/CleanupFileLocks.php
apps/files/lib/BackgroundJob/DeleteExpiredOpenLocalEditor.php
apps/files/lib/BackgroundJob/DeleteOrphanedItems.php
apps/files_external/lib/BackgroundJob/CredentialsCleanup.php
apps/files_reminders/lib/BackgroundJob/CleanUpReminders.php
apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php
apps/files_sharing/lib/ExpireSharesJob.php
apps/files_sharing/lib/SharesReminderJob.php
apps/oauth2/lib/BackgroundJob/CleanupExpiredAuthorizationCode.php
apps/twofactor_backupcodes/lib/BackgroundJob/RememberBackupCodesJob.php
apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php
apps/user_ldap/lib/Jobs/CleanUp.php
apps/user_status/lib/BackgroundJob/ClearOldStatusesBackgroundJob.php
core/BackgroundJobs/CleanupLoginFlowV2.php
core/BackgroundJobs/GenerateMetadataJob.php
lib/private/Preview/BackgroundCleanupJob.php
lib/private/Security/Bruteforce/CleanupJob.php
lib/private/TaskProcessing/RemoveOldTasksBackgroundJob.php
lib/private/TextProcessing/RemoveOldTasksBackgroundJob.php
lib/private/TextToImage/RemoveOldTasksBackgroundJob.php
lib/private/User/BackgroundJobs/CleanupDeletedUsers.php
lib/public/BackgroundJob/TimedJob.php

index 38fd0e155313c3f7acaed556ee7baf84d343dc12..b89a2c1fbb3cf085eb3c5f853037d9a608c28298 100644 (file)
@@ -10,7 +10,6 @@ namespace OCA\ContactsInteraction\BackgroundJob;
 
 use OCA\ContactsInteraction\Db\RecentContactMapper;
 use OCP\AppFramework\Utility\ITimeFactory;
-use OCP\BackgroundJob\IJob;
 use OCP\BackgroundJob\TimedJob;
 
 class CleanupJob extends TimedJob {
@@ -22,7 +21,7 @@ class CleanupJob extends TimedJob {
                parent::__construct($time);
 
                $this->setInterval(24 * 60 * 60);
-               $this->setTimeSensitivity(IJob::TIME_INSENSITIVE);
+               $this->setTimeSensitivity(self::TIME_INSENSITIVE);
 
        }
 
index 6d5eca6920c48fd95337448a3de73eacb80cb8e7..aa19dbb22ece84c9595dce128d98043ecce26ec8 100644 (file)
@@ -10,7 +10,6 @@ namespace OCA\DAV\BackgroundJob;
 
 use OC\User\NoUserException;
 use OCP\AppFramework\Utility\ITimeFactory;
-use OCP\BackgroundJob\IJob;
 use OCP\BackgroundJob\IJobList;
 use OCP\BackgroundJob\TimedJob;
 use OCP\Files\File;
@@ -32,7 +31,7 @@ class UploadCleanup extends TimedJob {
 
                // Run once a day
                $this->setInterval(60 * 60 * 24);
-               $this->setTimeSensitivity(IJob::TIME_INSENSITIVE);
+               $this->setTimeSensitivity(self::TIME_INSENSITIVE);
        }
 
        protected function run($argument) {
index 3ec9453c8056aab06c50c4021215e92d665f4dc9..7f41b20b9213365f6a0e18893e534dd3368f3fc6 100644 (file)
@@ -19,6 +19,7 @@ class SyncJob extends TimedJob {
                parent::__construct($timeFactory);
                // Run once a day
                $this->setInterval(24 * 60 * 60);
+               $this->setTimeSensitivity(self::TIME_INSENSITIVE);
                $this->syncService = $syncService;
                $this->logger = $logger;
        }
index 376e1049469ee4c56ed5f03771e5ad18b9551a1c..b2bbe4477dae5a968369575a7bc2d33e25d025b1 100644 (file)
@@ -13,14 +13,12 @@ use OCP\BackgroundJob\TimedJob;
 use OCP\DirectEditing\IManager;
 
 class CleanupDirectEditingTokens extends TimedJob {
-       private const INTERVAL_MINUTES = 15 * 60;
-
        private IManager $manager;
 
        public function __construct(ITimeFactory $time,
                IManager $manager) {
                parent::__construct($time);
-               $this->interval = self::INTERVAL_MINUTES;
+               $this->setInterval(15 * 60);
                $this->manager = $manager;
        }
 
index 69efb664302a9de53e4ad61fe968032f6c046fd9..a332c1434fcbe75d0e97e9cb910996a027dad689 100644 (file)
@@ -15,20 +15,12 @@ use OCP\BackgroundJob\TimedJob;
  * Clean up all file locks that are expired for the DB file locking provider
  */
 class CleanupFileLocks extends TimedJob {
-       /**
-        * Default interval in minutes
-        *
-        * @var int $defaultIntervalMin
-        **/
-       protected $defaultIntervalMin = 5;
-
        /**
         * sets the correct interval for this timed job
         */
        public function __construct(ITimeFactory $time) {
                parent::__construct($time);
-
-               $this->interval = $this->defaultIntervalMin * 60;
+               $this->setInterval(5 * 60);
        }
 
        /**
index ce2de9a74bbb906e48f2cd6eafad0363c54365bb..3a7aaa199d1fed5a1530694d04a42e8e240682b1 100644 (file)
@@ -11,7 +11,6 @@ namespace OCA\Files\BackgroundJob;
 
 use OCA\Files\Db\OpenLocalEditorMapper;
 use OCP\AppFramework\Utility\ITimeFactory;
-use OCP\BackgroundJob\IJob;
 use OCP\BackgroundJob\TimedJob;
 
 /**
@@ -29,7 +28,7 @@ class DeleteExpiredOpenLocalEditor extends TimedJob {
 
                // Run every 12h
                $this->interval = 12 * 3600;
-               $this->setTimeSensitivity(IJob::TIME_INSENSITIVE);
+               $this->setTimeSensitivity(self::TIME_INSENSITIVE);
        }
 
        /**
index b1a795b775cc9659aa43d81ce95d677ad1a2f8eb..b925974f24a431601379411a58c41ab9652bbc59 100644 (file)
@@ -18,7 +18,6 @@ use Psr\Log\LoggerInterface;
  */
 class DeleteOrphanedItems extends TimedJob {
        public const CHUNK_SIZE = 200;
-       protected $defaultIntervalMin = 60;
 
        /**
         * sets the correct interval for this timed job
@@ -29,7 +28,7 @@ class DeleteOrphanedItems extends TimedJob {
                protected LoggerInterface $logger,
        ) {
                parent::__construct($time);
-               $this->interval = $this->defaultIntervalMin * 60;
+               $this->setInterval(60 * 60);
        }
 
        /**
index 36eaa2d51ceaea19357f0e8ceac199586f2ea179..6d86c2f347b31d74abf09c2349f1cb03db20f1e7 100644 (file)
@@ -12,7 +12,6 @@ use OCA\Files_External\Lib\Auth\Password\LoginCredentials;
 use OCA\Files_External\Lib\StorageConfig;
 use OCA\Files_External\Service\UserGlobalStoragesService;
 use OCP\AppFramework\Utility\ITimeFactory;
-use OCP\BackgroundJob\IJob;
 use OCP\BackgroundJob\TimedJob;
 use OCP\IUser;
 use OCP\IUserManager;
@@ -37,7 +36,7 @@ class CredentialsCleanup extends TimedJob {
 
                // run every day
                $this->setInterval(24 * 60 * 60);
-               $this->setTimeSensitivity(IJob::TIME_INSENSITIVE);
+               $this->setTimeSensitivity(self::TIME_INSENSITIVE);
        }
 
        protected function run($argument) {
index 234e133ffc755165ab136bc0cc58f0d3abb76a10..35b72b190e83f61f69550dfd49cca9f26546b03b 100644 (file)
@@ -11,7 +11,6 @@ namespace OCA\FilesReminders\BackgroundJob;
 
 use OCA\FilesReminders\Service\ReminderService;
 use OCP\AppFramework\Utility\ITimeFactory;
-use OCP\BackgroundJob\IJob;
 use OCP\BackgroundJob\TimedJob;
 
 class CleanUpReminders extends TimedJob {
@@ -22,7 +21,7 @@ class CleanUpReminders extends TimedJob {
                parent::__construct($time);
 
                $this->setInterval(24 * 60 * 60); // 1 day
-               $this->setTimeSensitivity(IJob::TIME_INSENSITIVE);
+               $this->setTimeSensitivity(self::TIME_INSENSITIVE);
        }
 
        /**
index 9b1b0062ce5fdadab7a0d602bcfb60f0661b9877..44b473ac64d619c4b834dc5cf97167fa249a3cd0 100644 (file)
@@ -26,7 +26,8 @@ class FederatedSharesDiscoverJob extends TimedJob {
                private LoggerInterface $logger,
        ) {
                parent::__construct($time);
-               $this->setInterval(86400);
+               $this->setInterval(24 * 60 * 60);
+               $this->setTimeSensitivity(self::TIME_INSENSITIVE);
        }
 
        public function run($argument) {
index cd8490291d2835e9e32de7e65abd1bc66b23cbea..3900225092455d0630ec358616bb6a13f4946f75 100644 (file)
@@ -7,7 +7,6 @@
 namespace OCA\Files_Sharing;
 
 use OCP\AppFramework\Utility\ITimeFactory;
-use OCP\BackgroundJob\IJob;
 use OCP\BackgroundJob\TimedJob;
 use OCP\IDBConnection;
 use OCP\Share\Exceptions\ShareNotFound;
@@ -33,7 +32,7 @@ class ExpireSharesJob extends TimedJob {
 
                // Run once a day
                $this->setInterval(24 * 60 * 60);
-               $this->setTimeSensitivity(IJob::TIME_INSENSITIVE);
+               $this->setTimeSensitivity(self::TIME_INSENSITIVE);
        }
 
 
index af279bbc146d2def3a03882771b2dfb682bbe718..b3b3590ec0954a13ca4aa24eab595690159e0348 100644 (file)
@@ -33,7 +33,7 @@ use Psr\Log\LoggerInterface;
  * Send a reminder via email to the sharee(s) if the folder is still empty a predefined time before the expiration date
  */
 class SharesReminderJob extends TimedJob {
-       private const SECONDS_BEFORE_REMINDER = 86400;
+       private const SECONDS_BEFORE_REMINDER = 24 * 60 * 60;
        private const CHUNK_SIZE = 1000;
        private int $folderMimeTypeId;
 
@@ -50,7 +50,7 @@ class SharesReminderJob extends TimedJob {
                IMimeTypeLoader                  $mimeTypeLoader,
        ) {
                parent::__construct($time);
-               $this->setInterval(3600);
+               $this->setInterval(60 * 60);
                $this->folderMimeTypeId = $mimeTypeLoader->getId(ICacheEntry::DIRECTORY_MIMETYPE);
        }
 
index d1647381ffa76f783d93282f5668b136abd6cf3b..b819a45ace28fb6c914d03c5df1c9877e4b93d82 100644 (file)
@@ -12,7 +12,6 @@ namespace OCA\OAuth2\BackgroundJob;
 
 use OCA\OAuth2\Db\AccessTokenMapper;
 use OCP\AppFramework\Utility\ITimeFactory;
-use OCP\BackgroundJob\IJob;
 use OCP\BackgroundJob\TimedJob;
 use OCP\DB\Exception;
 use Psr\Log\LoggerInterface;
@@ -27,7 +26,7 @@ class CleanupExpiredAuthorizationCode extends TimedJob {
                parent::__construct($timeFactory);
                // 30 days
                $this->setInterval(60 * 60 * 24 * 30);
-               $this->setTimeSensitivity(IJob::TIME_INSENSITIVE);
+               $this->setTimeSensitivity(self::TIME_INSENSITIVE);
        }
 
        /**
index 2bf182d59fd68256a2bf81942c0132d9f62ecf8d..61b93803a0d6749b4683e161c98c0987b8fb2335 100644 (file)
@@ -10,7 +10,6 @@ namespace OCA\TwoFactorBackupCodes\BackgroundJob;
 
 use OCP\AppFramework\Utility\ITimeFactory;
 use OCP\Authentication\TwoFactorAuth\IRegistry;
-use OCP\BackgroundJob\IJob;
 use OCP\BackgroundJob\IJobList;
 use OCP\BackgroundJob\TimedJob;
 use OCP\IUserManager;
@@ -43,7 +42,7 @@ class RememberBackupCodesJob extends TimedJob {
                $this->jobList = $jobList;
 
                $this->setInterval(60 * 60 * 24 * 14);
-               $this->setTimeSensitivity(IJob::TIME_INSENSITIVE);
+               $this->setTimeSensitivity(self::TIME_INSENSITIVE);
        }
 
        protected function run($argument) {
index 30786f5e12d28f8af893eb89376a41c68fd6a3ea..7f8402570bc12649d8df8767ec07beaf90b2b87a 100644 (file)
@@ -40,6 +40,7 @@ class UpdateAvailableNotifications extends TimedJob {
                parent::__construct($timeFactory);
                // Run once a day
                $this->setInterval(60 * 60 * 24);
+               $this->setTimeSensitivity(self::TIME_INSENSITIVE);
        }
 
        protected function run($argument) {
index b04dc67ef49231419ce1f805b6714ce25b3c7b73..088a563dc2750947b5a09aab2f51114501f5089a 100644 (file)
@@ -27,7 +27,7 @@ class CleanUp extends TimedJob {
        protected $limit;
 
        /** @var int $defaultIntervalMin default interval in minutes */
-       protected $defaultIntervalMin = 51;
+       protected $defaultIntervalMin = 60;
 
        /** @var User_LDAP|User_Proxy $userBackend */
        protected $userBackend;
index 1810f7aa1186c7be7644e417f5446c848482eab4..edf3b65772402d8f03faf8be0799b34d17c0c699 100644 (file)
@@ -35,7 +35,7 @@ class ClearOldStatusesBackgroundJob extends TimedJob {
                $this->mapper = $mapper;
 
                // Run every time the cron is run
-               $this->setInterval(60);
+               $this->setInterval(0);
        }
 
        /**
index 0a95bf9157948fd00d997b11096245c8f972417a..e5bcf00a921a32c602de3e04ed2af88a2844e25d 100644 (file)
@@ -19,7 +19,7 @@ class CleanupLoginFlowV2 extends TimedJob {
        ) {
                parent::__construct($time);
 
-               $this->setInterval(3600);
+               $this->setInterval(60 * 60);
        }
 
        protected function run($argument): void {
index b3fcf892720020f5e4e3dc2be92f372bbf47ebf9..e775717092abe2c73dc92295c50b8791665e8981 100644 (file)
@@ -36,8 +36,8 @@ class GenerateMetadataJob extends TimedJob {
        ) {
                parent::__construct($time);
 
-               $this->setTimeSensitivity(\OCP\BackgroundJob\IJob::TIME_INSENSITIVE);
-               $this->setInterval(24 * 3600);
+               $this->setTimeSensitivity(self::TIME_INSENSITIVE);
+               $this->setInterval(24 * 60 * 60);
        }
 
        protected function run(mixed $argument): void {
index 8449e73983cb7678f54d35e6a76186a2584777a0..ad5e793474b91861ce52f6bc870607a51ca83c84 100644 (file)
@@ -37,7 +37,8 @@ class BackgroundCleanupJob extends TimedJob {
                bool $isCLI) {
                parent::__construct($timeFactory);
                // Run at most once an hour
-               $this->setInterval(3600);
+               $this->setInterval(60 * 60);
+               $this->setTimeSensitivity(self::TIME_INSENSITIVE);
 
                $this->connection = $connection;
                $this->previewFolder = $previewFolder;
index e7d981caa08c55fa7f3c80a83c215eb164299746..fdf7fb97d3188050fd5e71b5fc56cef876bce926 100644 (file)
@@ -9,7 +9,6 @@ declare(strict_types=1);
 namespace OC\Security\Bruteforce;
 
 use OCP\AppFramework\Utility\ITimeFactory;
-use OCP\BackgroundJob\IJob;
 use OCP\BackgroundJob\TimedJob;
 use OCP\DB\QueryBuilder\IQueryBuilder;
 use OCP\IDBConnection;
@@ -22,8 +21,8 @@ class CleanupJob extends TimedJob {
                parent::__construct($time);
 
                // Run once a day
-               $this->setInterval(3600 * 24);
-               $this->setTimeSensitivity(IJob::TIME_INSENSITIVE);
+               $this->setInterval(60 * 60 * 24);
+               $this->setTimeSensitivity(self::TIME_INSENSITIVE);
        }
 
        protected function run($argument): void {
index acec2f46c055d074555148b877f84bc008e06a33..c6f26e3aa8b6560c0ae39b073ef410bc7bd4435f 100644 (file)
@@ -16,7 +16,7 @@ use OCP\Files\SimpleFS\ISimpleFolder;
 use Psr\Log\LoggerInterface;
 
 class RemoveOldTasksBackgroundJob extends TimedJob {
-       public const MAX_TASK_AGE_SECONDS = 60 * 50 * 24 * 7 * 4; // 4 weeks
+       public const MAX_TASK_AGE_SECONDS = 60 * 60 * 24 * 7 * 4; // 4 weeks
        private \OCP\Files\IAppData $appData;
 
        public function __construct(
@@ -28,7 +28,7 @@ class RemoveOldTasksBackgroundJob extends TimedJob {
                parent::__construct($timeFactory);
                $this->setInterval(60 * 60 * 24);
                // can be deferred to maintenance window
-               $this->setTimeSensitivity(TimedJob::TIME_INSENSITIVE);
+               $this->setTimeSensitivity(self::TIME_INSENSITIVE);
                $this->appData = $appDataFactory->get('core');
        }
 
index 4a336d56077bb58c66c52cefd19ba6cf6baeb72f..be5e4127d08fa4cda8348b8132840b68d621a773 100644 (file)
@@ -17,7 +17,7 @@ use OCP\DB\Exception;
 use Psr\Log\LoggerInterface;
 
 class RemoveOldTasksBackgroundJob extends TimedJob {
-       public const MAX_TASK_AGE_SECONDS = 60 * 50 * 24 * 7; // 1 week
+       public const MAX_TASK_AGE_SECONDS = 60 * 60 * 24 * 7; // 1 week
 
        public function __construct(
                ITimeFactory $timeFactory,
@@ -26,6 +26,7 @@ class RemoveOldTasksBackgroundJob extends TimedJob {
        ) {
                parent::__construct($timeFactory);
                $this->setInterval(60 * 60 * 24);
+               $this->setTimeSensitivity(self::TIME_INSENSITIVE);
        }
 
        /**
index 7d9170090b713aa19b9ce6bab604dd9488f74fa6..225984a7956ff50bf119f8c92c095cb7b2759809 100644 (file)
@@ -21,7 +21,7 @@ use OCP\Files\NotPermittedException;
 use Psr\Log\LoggerInterface;
 
 class RemoveOldTasksBackgroundJob extends TimedJob {
-       public const MAX_TASK_AGE_SECONDS = 60 * 50 * 24 * 7; // 1 week
+       public const MAX_TASK_AGE_SECONDS = 60 * 60 * 24 * 7; // 1 week
 
        private IAppData $appData;
 
@@ -34,6 +34,7 @@ class RemoveOldTasksBackgroundJob extends TimedJob {
                parent::__construct($timeFactory);
                $this->appData = $appDataFactory->get('core');
                $this->setInterval(60 * 60 * 24);
+               $this->setTimeSensitivity(self::TIME_INSENSITIVE);
        }
 
        /**
index 3c1b73637acdbae894f93feb3d43288844a1027c..f999031a2a90a5cbb9b1bcb280b5201bd58d43dd 100644 (file)
@@ -12,7 +12,6 @@ use OC\User\Manager;
 use OC\User\PartiallyDeletedUsersBackend;
 use OC\User\User;
 use OCP\AppFramework\Utility\ITimeFactory;
-use OCP\BackgroundJob\IJob;
 use OCP\BackgroundJob\TimedJob;
 use OCP\EventDispatcher\IEventDispatcher;
 use OCP\IConfig;
@@ -26,8 +25,8 @@ class CleanupDeletedUsers extends TimedJob {
                private LoggerInterface $logger,
        ) {
                parent::__construct($time);
-               $this->setTimeSensitivity(IJob::TIME_INSENSITIVE);
-               $this->setInterval(24 * 3600);
+               $this->setTimeSensitivity(self::TIME_INSENSITIVE);
+               $this->setInterval(24 * 60 * 60);
        }
 
        protected function run($argument): void {
index bec3f21fe16dfa65c6791644968c628839d5121d..6a81e841460080dd5eaf41410182ea68e1455916 100644 (file)
@@ -52,8 +52,8 @@ abstract class TimedJob extends Job {
         * @since 24.0.0
         */
        public function setTimeSensitivity(int $sensitivity): void {
-               if ($sensitivity !== IJob::TIME_SENSITIVE &&
-                       $sensitivity !== IJob::TIME_INSENSITIVE) {
+               if ($sensitivity !== self::TIME_SENSITIVE &&
+                       $sensitivity !== self::TIME_INSENSITIVE) {
                        throw new \InvalidArgumentException('Invalid sensitivity');
                }