Skip to content

Commit

Permalink
enh(metadata): Introduce a memory limit for metadata generation
Browse files Browse the repository at this point in the history
Signed-off-by: Git'Fellow <[email protected]>
  • Loading branch information
solracsf authored Jan 15, 2024
1 parent 32bf74a commit e65120d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/BackgroundJobs/GenerateMetadataJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
use Psr\Log\LoggerInterface;

class GenerateMetadataJob extends TimedJob {
// Default memory limit for metadata generation (256 MBytes).
protected const DEFAULT_MEMORY_LIMIT = 256;

public function __construct(
ITimeFactory $time,
private IConfig $config,
Expand Down Expand Up @@ -100,6 +103,14 @@ private function scanFolder(Folder $folder): void {
continue;
}

// Don't generate metadata for files bigger than metadata_max_memory
$nodeSize = $node->getSize();
$memoryLimit = $this->config->getSystemValueInt('metadata_max_memory', self::DEFAULT_MEMORY_LIMIT);
if ($nodeSize > $memoryLimit) {
$this->logger->debug("Skipping generating metadata for fileid " . $node->getId() . " as its size exceeds configured 'metadata_max_memory'.");
continue;
}

try {
$this->filesMetadataManager->getMetadata($node->getId(), false);
} catch (FilesMetadataNotFoundException) {
Expand Down

0 comments on commit e65120d

Please sign in to comment.