From e5865b826f3915ad0edf38d0613a2a6c74e13a31 Mon Sep 17 00:00:00 2001 From: Louis Chmn Date: Tue, 3 Feb 2026 11:57:50 +0100 Subject: [PATCH] fix: Migrate `getById` to `getFirstNodeById` Signed-off-by: Louis Chmn --- lib/Classifiers/Classifier.php | 16 ++++++++-------- lib/Hooks/FileListener.php | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/Classifiers/Classifier.php b/lib/Classifiers/Classifier.php index 7737c2047..6c2e4b12f 100644 --- a/lib/Classifiers/Classifier.php +++ b/lib/Classifiers/Classifier.php @@ -79,8 +79,8 @@ public function classifyFiles(string $model, array $queueFiles, int $timeout): \ if ($this->maxExecutionTime > 0 && time() - $startTime > $this->maxExecutionTime) { return; } - $files = $this->rootFolder->getById($queueFile->getFileId()); - if (count($files) === 0) { + $file = $this->rootFolder->getFirstNodeById($queueFile->getFileId()); + if ($file === null) { try { $this->logger->debug('removing '.$queueFile->getFileId().' from '.$model.' queue because it couldn\'t be found'); $this->queue->removeFromQueue($model, $queueFile); @@ -90,8 +90,8 @@ public function classifyFiles(string $model, array $queueFiles, int $timeout): \ continue; } try { - if ($files[0]->getSize() == 0) { - $this->logger->debug('File is empty: ' . $files[0]->getPath()); + if ($file->getSize() == 0) { + $this->logger->debug('File is empty: ' . $file->getPath()); try { $this->logger->debug('removing ' . $queueFile->getFileId() . ' from ' . $model . ' queue'); $this->queue->removeFromQueue($model, $queueFile); @@ -100,14 +100,14 @@ public function classifyFiles(string $model, array $queueFiles, int $timeout): \ } continue; } - $path = $this->getConvertedFilePath($files[0]); + $path = $this->getConvertedFilePath($file); if (in_array($model, [ImagenetClassifier::MODEL_NAME, LandmarksClassifier::MODEL_NAME, ClusteringFaceClassifier::MODEL_NAME], true)) { // Check file data size $filesize = filesize($path); if ($filesize !== false) { $filesizeMb = $filesize / (1024 * 1024); if ($filesizeMb > 8) { - $this->logger->debug('File is too large for classifier: ' . $files[0]->getPath()); + $this->logger->debug('File is too large for classifier: ' . $file->getPath()); try { $this->logger->debug('removing ' . $queueFile->getFileId() . ' from ' . $model . ' queue'); $this->queue->removeFromQueue($model, $queueFile); @@ -120,7 +120,7 @@ public function classifyFiles(string $model, array $queueFiles, int $timeout): \ // Check file dimensions $dimensions = @getimagesize($path); if (isset($dimensions) && $dimensions !== false && ($dimensions[0] > 1024 || $dimensions[1] > 1024)) { - $this->logger->debug('File dimensions are too large for classifier: ' . $files[0]->getPath()); + $this->logger->debug('File dimensions are too large for classifier: ' . $file->getPath()); try { $this->logger->debug('removing ' . $queueFile->getFileId() . ' from ' . $model . ' queue'); $this->queue->removeFromQueue($model, $queueFile); @@ -132,7 +132,7 @@ public function classifyFiles(string $model, array $queueFiles, int $timeout): \ } $paths[] = $path; $processedFiles[] = $queueFile; - $fileNames[] = $files[0]->getPath(); + $fileNames[] = $file->getPath(); } catch (NotFoundException|InvalidPathException $e) { $this->logger->warning('Could not find file', ['exception' => $e]); try { diff --git a/lib/Hooks/FileListener.php b/lib/Hooks/FileListener.php index d0b0ebe7d..ad7d966b0 100644 --- a/lib/Hooks/FileListener.php +++ b/lib/Hooks/FileListener.php @@ -265,7 +265,7 @@ public function handle(Event $event): void { return; } if ($event instanceof CacheEntryInsertedEvent) { - $node = current($this->rootFolder->getById($event->getFileId())); + $node = $this->rootFolder->getFirstNodeById($event->getFileId()); if ($node === false) { return; } @@ -284,7 +284,7 @@ public function handle(Event $event): void { if ($cacheEntry === false) { return; } - $node = current($this->rootFolder->getById($cacheEntry->getId())); + $node = $this->rootFolder->getFirstNodeById($cacheEntry->getId()); if ($node === false) { return; } @@ -546,7 +546,7 @@ private function onAccessUpdate(int $storageId, int $rootId): void { $files = $this->storageService->getFilesInMount($storageId, $rootId, [ClusteringFaceClassifier::MODEL_NAME], 0, 0); $userIdsToScheduleClustering = []; foreach ($files as $fileInfo) { - $node = current($this->rootFolder->getById($fileInfo['fileid'])) ?: null; + $node = $this->rootFolder->getFirstNodeById($fileInfo['fileid']) ?: null; $ownerId = $node?->getOwner()?->getUID(); if ($ownerId === null) { continue;