Skip to content

Commit 543b46f

Browse files
CarlSchwanAndyScherzinger
authored andcommitted
fix(preview): Fix scanning preview
Make sure we set the mimetype string representation and not int representation. Signed-off-by: Carl Schwan <[email protected]>
1 parent 9cd337b commit 543b46f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/private/Preview/Storage/LocalPreviewStorage.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use OC\Preview\Db\PreviewMapper;
1818
use OCP\DB\Exception;
1919
use OCP\Files\IMimeTypeDetector;
20+
use OCP\Files\IMimeTypeLoader;
2021
use OCP\Files\NotFoundException;
2122
use OCP\Files\NotPermittedException;
2223
use OCP\IAppConfig;
@@ -40,6 +41,7 @@ public function __construct(
4041
private readonly IMimeTypeDetector $mimeTypeDetector,
4142
private readonly LoggerInterface $logger,
4243
private readonly ISnowflakeGenerator $generator,
44+
private readonly IMimeTypeLoader $mimeTypeLoader,
4345
) {
4446
$this->instanceId = $this->config->getSystemValueString('instanceid');
4547
$this->rootFolder = $this->config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data');
@@ -133,9 +135,9 @@ public function scan(): int {
133135
->setMaxResults(1)
134136
->runAcrossAllShards() // Unavoidable because we can't extract the storage_id from the preview name
135137
->executeQuery()
136-
->fetchAll();
138+
->fetchAssociative();
137139

138-
if (empty($result)) {
140+
if ($result === false) {
139141
// original file is deleted
140142
@unlink($file->getRealPath());
141143
continue;
@@ -151,9 +153,9 @@ public function scan(): int {
151153
}
152154
}
153155

154-
$preview->setStorageId($result[0]['storage']);
155-
$preview->setEtag($result[0]['etag']);
156-
$preview->setSourceMimetype($result[0]['mimetype']);
156+
$preview->setStorageId($result['storage']);
157+
$preview->setEtag($result['etag']);
158+
$preview->setSourceMimetype($this->mimeTypeLoader->getMimetypeById($result['mimetype']));
157159
$preview->generateId();
158160
// try to insert, if that fails the preview is already in the DB
159161
$this->previewMapper->insert($preview);

0 commit comments

Comments
 (0)