From 78de15ab45581c90b0fd215a0e1726aca7ca6766 Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Wed, 13 Dec 2023 10:40:20 +0100 Subject: [PATCH] Wrap metadata generation in try/catch Signed-off-by: Louis Chemineau --- core/BackgroundJobs/GenerateMetadataJob.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/BackgroundJobs/GenerateMetadataJob.php b/core/BackgroundJobs/GenerateMetadataJob.php index f0dfdb8de2210..393545b097d0a 100644 --- a/core/BackgroundJobs/GenerateMetadataJob.php +++ b/core/BackgroundJobs/GenerateMetadataJob.php @@ -33,6 +33,7 @@ use OCP\FilesMetadata\IFilesMetadataManager; use OCP\IConfig; use OCP\IUserManager; +use Psr\Log\LoggerInterface; class GenerateMetadataJob extends TimedJob { public function __construct( @@ -42,6 +43,7 @@ public function __construct( private IUserManager $userManager, private IFilesMetadataManager $filesMetadataManager, private IJobList $jobList, + private LoggerInterface $logger, ) { parent::__construct($time); @@ -102,10 +104,14 @@ private function scanFolder(Folder $folder): void { continue; } - $this->filesMetadataManager->refreshMetadata( - $node, - IFilesMetadataManager::PROCESS_LIVE | IFilesMetadataManager::PROCESS_BACKGROUND - ); + try { + $this->filesMetadataManager->refreshMetadata( + $node, + IFilesMetadataManager::PROCESS_LIVE | IFilesMetadataManager::PROCESS_BACKGROUND + ); + } catch (\Throwable $ex) { + $this->logger->warning("Error while generating metadata for fileid ".$node->getId(), ['exception' => $ex]); + } } } }