diff options
-rw-r--r-- | core/BackgroundJobs/GenerateMetadataJob.php | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/core/BackgroundJobs/GenerateMetadataJob.php b/core/BackgroundJobs/GenerateMetadataJob.php index b584a771fbb..b42cca13ef9 100644 --- a/core/BackgroundJobs/GenerateMetadataJob.php +++ b/core/BackgroundJobs/GenerateMetadataJob.php @@ -9,6 +9,7 @@ declare(strict_types=1); namespace OC\Core\BackgroundJobs; use OC\Files\Mount\MoveableMount; +use OC\FilesMetadata\Job\UpdateSingleMetadata; use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\IJobList; use OCP\BackgroundJob\TimedJob; @@ -46,6 +47,13 @@ class GenerateMetadataJob extends TimedJob { return; } + // This prevent the job from piling up UpdateSingleMetadata jobs + $pendingUpdateSingleMetadataJobs = $this->jobList->countByClass(UpdateSingleMetadata::class); + if (isset($pendingUpdateSingleMetadataJobs[0]) && $pendingUpdateSingleMetadataJobs[0]['count'] > 1000) { + $this->logger->debug('Skipping metadata generation job as there are more than 1000 pending UpdateSingleMetadata jobs.'); + return; + } + $offset = $this->appConfig->getValueInt('core', 'metadataGenerationOffset', 0); $users = $this->userManager->getSeenUsers($offset); |