Skip to content

Commit 02eb3c7

Browse files
authored
Merge pull request #1449 from nextcloud/artonge/fix/getById
fix: Migrate `getById` to `getFirstNodeById`
2 parents e5dc7df + f738133 commit 02eb3c7

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

lib/Classifiers/Classifier.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ public function classifyFiles(string $model, array $queueFiles, int $timeout): \
7878
if ($this->maxExecutionTime > 0 && time() - $startTime > $this->maxExecutionTime) {
7979
return;
8080
}
81-
$files = $this->rootFolder->getById($queueFile->getFileId());
82-
if (count($files) === 0) {
81+
$file = $this->rootFolder->getFirstNodeById($queueFile->getFileId());
82+
if ($file === null) {
8383
try {
8484
$this->logger->debug('removing '.$queueFile->getFileId().' from '.$model.' queue because it couldn\'t be found');
8585
$this->queue->removeFromQueue($model, $queueFile);
@@ -89,8 +89,8 @@ public function classifyFiles(string $model, array $queueFiles, int $timeout): \
8989
continue;
9090
}
9191
try {
92-
if ($files[0]->getSize() == 0) {
93-
$this->logger->debug('File is empty: ' . $files[0]->getPath());
92+
if ($file->getSize() == 0) {
93+
$this->logger->debug('File is empty: ' . $file->getPath());
9494
try {
9595
$this->logger->debug('removing ' . $queueFile->getFileId() . ' from ' . $model . ' queue');
9696
$this->queue->removeFromQueue($model, $queueFile);
@@ -99,14 +99,14 @@ public function classifyFiles(string $model, array $queueFiles, int $timeout): \
9999
}
100100
continue;
101101
}
102-
$path = $this->getConvertedFilePath($files[0]);
102+
$path = $this->getConvertedFilePath($file);
103103
if (in_array($model, [ImagenetClassifier::MODEL_NAME, LandmarksClassifier::MODEL_NAME, ClusteringFaceClassifier::MODEL_NAME], true)) {
104104
// Check file data size
105105
$filesize = filesize($path);
106106
if ($filesize !== false) {
107107
$filesizeMb = $filesize / (1024 * 1024);
108108
if ($filesizeMb > 8) {
109-
$this->logger->debug('File is too large for classifier: ' . $files[0]->getPath());
109+
$this->logger->debug('File is too large for classifier: ' . $file->getPath());
110110
try {
111111
$this->logger->debug('removing ' . $queueFile->getFileId() . ' from ' . $model . ' queue');
112112
$this->queue->removeFromQueue($model, $queueFile);
@@ -119,7 +119,7 @@ public function classifyFiles(string $model, array $queueFiles, int $timeout): \
119119
// Check file dimensions
120120
$dimensions = @getimagesize($path);
121121
if (isset($dimensions) && $dimensions !== false && ($dimensions[0] > 1024 || $dimensions[1] > 1024)) {
122-
$this->logger->debug('File dimensions are too large for classifier: ' . $files[0]->getPath());
122+
$this->logger->debug('File dimensions are too large for classifier: ' . $file->getPath());
123123
try {
124124
$this->logger->debug('removing ' . $queueFile->getFileId() . ' from ' . $model . ' queue');
125125
$this->queue->removeFromQueue($model, $queueFile);
@@ -131,7 +131,7 @@ public function classifyFiles(string $model, array $queueFiles, int $timeout): \
131131
}
132132
$paths[] = $path;
133133
$processedFiles[] = $queueFile;
134-
$fileNames[] = $files[0]->getPath();
134+
$fileNames[] = $file->getPath();
135135
} catch (NotFoundException|InvalidPathException $e) {
136136
$this->logger->warning('Could not find file', ['exception' => $e]);
137137
try {

lib/Service/FsActionService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ private function onAccessUpdate(int $storageId, int $rootId): void {
168168
$files = $this->storageService->getFilesInMount($storageId, $rootId, [ClusteringFaceClassifier::MODEL_NAME], 0, 0);
169169
$userIdsToScheduleClustering = [];
170170
foreach ($files as $fileInfo) {
171-
$node = current($this->rootFolder->getById($fileInfo['fileid'])) ?: null;
171+
$node = $this->rootFolder->getFirstNodeById($fileInfo['fileid']) ?: null;
172172
$ownerId = $node?->getOwner()?->getUID();
173173
if ($ownerId === null) {
174174
continue;

0 commit comments

Comments
 (0)