From f7381334a637c89e31daf96c031415c639d204f5 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/Service/FsActionService.php | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/Classifiers/Classifier.php b/lib/Classifiers/Classifier.php index 43c0162ce..92e0657d4 100644 --- a/lib/Classifiers/Classifier.php +++ b/lib/Classifiers/Classifier.php @@ -78,8 +78,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); @@ -89,8 +89,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); @@ -99,14 +99,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); @@ -119,7 +119,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); @@ -131,7 +131,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/Service/FsActionService.php b/lib/Service/FsActionService.php index 3f8b3579d..c99c59450 100644 --- a/lib/Service/FsActionService.php +++ b/lib/Service/FsActionService.php @@ -168,7 +168,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;