Skip to content

Commit f6c411e

Browse files
marcelklehrbackportbot[bot]
authored andcommitted
fix(Classifier): Do not get stuck when decryption fails
fixes #1302 Signed-off-by: Marcel Klehr <mklehr@gmx.net>
1 parent 820bc73 commit f6c411e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/Classifiers/Classifier.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use OCA\Recognize\Service\QueueService;
1616
use OCP\AppFramework\Services\IAppConfig;
1717
use OCP\DB\Exception;
18+
use OCP\Encryption\Exceptions\GenericEncryptionException;
1819
use OCP\Files\File;
1920
use OCP\Files\InvalidPathException;
2021
use OCP\Files\IRootFolder;
@@ -140,6 +141,14 @@ public function classifyFiles(string $model, array $queueFiles, int $timeout): \
140141
$this->logger->warning($e->getMessage(), ['exception' => $e]);
141142
}
142143
continue;
144+
} catch (GenericEncryptionException $e) {
145+
$this->logger->warning('Could not load encrypted file', ['exception' => $e]);
146+
try {
147+
$this->queue->removeFromQueue($model, $queueFile);
148+
} catch (Exception $e) {
149+
$this->logger->warning($e->getMessage(), ['exception' => $e]);
150+
}
151+
continue;
143152
}
144153
}
145154

@@ -261,6 +270,7 @@ public function classifyFiles(string $model, array $queueFiles, int $timeout): \
261270
* @param \OCP\Files\Node $file
262271
* @return string Path to file to process
263272
* @throws \OCP\Files\NotFoundException
273+
* @throws GenericEncryptionException
264274
*/
265275
private function getConvertedFilePath(Node $file): string {
266276
if (!$file instanceof File) {
@@ -292,9 +302,9 @@ private function getConvertedFilePath(Node $file): string {
292302
if ($imageType > 0) {
293303
$this->logger->debug('generating preview of ' . $file->getId() . ' with dimension ' . self::TEMP_FILE_DIMENSION . ' using gdlib');
294304
return $this->generatePreviewWithGD($path);
295-
} else {
296-
return $path;
297305
}
306+
307+
return $path;
298308
} catch (\Throwable $e) {
299309
$this->logger->warning('Failed to generate preview of ' . $file->getId() . ' with dimension ' . self::TEMP_FILE_DIMENSION . ' with gdlib: ' . $e->getMessage());
300310
return $path;

0 commit comments

Comments
 (0)