aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2024-05-13 08:55:04 +0200
committerMarcel Klehr <mklehr@gmx.net>2024-05-14 11:38:42 +0200
commitac36c788d764e354b9d8b9ab0bea918e04c39e32 (patch)
tree71d50574fdd40eb15b824f46b4e7bc75881886ec /lib
parentb11052fcfa8b76618b81f64af3987b4382256264 (diff)
downloadnextcloud-server-ac36c788d764e354b9d8b9ab0bea918e04c39e32.tar.gz
nextcloud-server-ac36c788d764e354b9d8b9ab0bea918e04c39e32.zip
fix(SynchronousBackgroundJob): Only reschedule when needed
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/TaskProcessing/SynchronousBackgroundJob.php21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/private/TaskProcessing/SynchronousBackgroundJob.php b/lib/private/TaskProcessing/SynchronousBackgroundJob.php
index ee6064aa4c6..d282d21f113 100644
--- a/lib/private/TaskProcessing/SynchronousBackgroundJob.php
+++ b/lib/private/TaskProcessing/SynchronousBackgroundJob.php
@@ -79,7 +79,24 @@ class SynchronousBackgroundJob extends QueuedJob {
}
}
- // Schedule again
- $this->jobList->add(self::class, $argument);
+ $synchronousProviders = array_filter($providers, fn ($provider) =>
+ $provider instanceof ISynchronousProvider);
+ $taskTypes = array_values(array_map(fn ($provider) =>
+ $provider->getTaskTypeId(),
+ $synchronousProviders
+ ));
+ $taskTypesWithTasks = array_filter($taskTypes, function ($taskType) {
+ try {
+ $this->taskProcessingManager->getNextScheduledTask($taskType);
+ return true;
+ } catch (NotFoundException|Exception $e) {
+ return false;
+ }
+ });
+
+ if (count($taskTypesWithTasks) > 0) {
+ // Schedule again
+ $this->jobList->add(self::class, $argument);
+ }
}
}