Skip to content

Commit

Permalink
Merge pull request #42263 from nextcloud/backport/42198/stable28
Browse files Browse the repository at this point in the history
[stable28] Wrap metadata generation in try/catch
  • Loading branch information
artonge authored Dec 14, 2023
2 parents 892c0bf + 78de15a commit 056401b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions core/BackgroundJobs/GenerateMetadataJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -42,6 +43,7 @@ public function __construct(
private IUserManager $userManager,
private IFilesMetadataManager $filesMetadataManager,
private IJobList $jobList,
private LoggerInterface $logger,
) {
parent::__construct($time);

Expand Down Expand Up @@ -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]);
}
}
}
}

0 comments on commit 056401b

Please sign in to comment.