Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/Classifiers/Classifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/FsActionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading