aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/TaskProcessing
diff options
context:
space:
mode:
authorJulien Veyssier <julien-nc@posteo.net>2024-08-27 13:22:12 +0200
committerJulien Veyssier <julien-nc@posteo.net>2024-08-27 14:59:20 +0200
commit396b8f52f1e5ea8a9005911179762492bbbe5e88 (patch)
tree4276b171d75a84d6682d4967f45e9ada5b3b2804 /lib/private/TaskProcessing
parentc1ed256d50a2f365060e2827be8893145073e434 (diff)
downloadnextcloud-server-396b8f52f1e5ea8a9005911179762492bbbe5e88.tar.gz
nextcloud-server-396b8f52f1e5ea8a9005911179762492bbbe5e88.zip
fix(taskprocessing): fix condition to reschedule SynchronousBackgroundJob
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Diffstat (limited to 'lib/private/TaskProcessing')
-rw-r--r--lib/private/TaskProcessing/SynchronousBackgroundJob.php23
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/private/TaskProcessing/SynchronousBackgroundJob.php b/lib/private/TaskProcessing/SynchronousBackgroundJob.php
index 3d85625da8f..de3b424176c 100644
--- a/lib/private/TaskProcessing/SynchronousBackgroundJob.php
+++ b/lib/private/TaskProcessing/SynchronousBackgroundJob.php
@@ -9,14 +9,8 @@ namespace OC\TaskProcessing;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\BackgroundJob\QueuedJob;
-use OCP\Files\GenericFileException;
-use OCP\Files\NotPermittedException;
-use OCP\Lock\LockedException;
use OCP\TaskProcessing\Exception\Exception;
use OCP\TaskProcessing\Exception\NotFoundException;
-use OCP\TaskProcessing\Exception\ProcessingException;
-use OCP\TaskProcessing\Exception\UnauthorizedException;
-use OCP\TaskProcessing\Exception\ValidationException;
use OCP\TaskProcessing\IManager;
use OCP\TaskProcessing\ISynchronousProvider;
use OCP\TaskProcessing\Task;
@@ -63,12 +57,21 @@ class SynchronousBackgroundJob extends QueuedJob {
}
}
+ // check if this job needs to be scheduled again:
+ // if there is at least one preferred synchronous provider that has a scheduled task
$synchronousProviders = array_filter($providers, fn ($provider) =>
$provider instanceof ISynchronousProvider);
- $taskTypes = array_values(array_map(fn ($provider) =>
- $provider->getTaskTypeId(),
- $synchronousProviders
- ));
+ $synchronousPreferredProviders = array_filter($synchronousProviders, function ($provider) {
+ $taskTypeId = $provider->getTaskTypeId();
+ $preferredProvider = $this->taskProcessingManager->getPreferredProvider($taskTypeId);
+ return $provider->getId() === $preferredProvider->getId();
+ });
+ $taskTypes = array_values(
+ array_map(
+ fn ($provider) => $provider->getTaskTypeId(),
+ $synchronousPreferredProviders
+ )
+ );
$taskTypesWithTasks = array_filter($taskTypes, function ($taskType) {
try {
$this->taskProcessingManager->getNextScheduledTask([$taskType]);