Skip to content
Open
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
12 changes: 7 additions & 5 deletions lib/private/Preview/Storage/LocalPreviewStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use OC\Preview\Db\PreviewMapper;
use OCP\DB\Exception;
use OCP\Files\IMimeTypeDetector;
use OCP\Files\IMimeTypeLoader;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\IAppConfig;
Expand All @@ -40,6 +41,7 @@ public function __construct(
private readonly IMimeTypeDetector $mimeTypeDetector,
private readonly LoggerInterface $logger,
private readonly ISnowflakeGenerator $generator,
private readonly IMimeTypeLoader $mimeTypeLoader,
) {
$this->instanceId = $this->config->getSystemValueString('instanceid');
$this->rootFolder = $this->config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data');
Expand Down Expand Up @@ -133,9 +135,9 @@ public function scan(): int {
->setMaxResults(1)
->runAcrossAllShards() // Unavoidable because we can't extract the storage_id from the preview name
->executeQuery()
->fetchAll();
->fetchAssociative();

if (empty($result)) {
if ($result === false) {
// original file is deleted
@unlink($file->getRealPath());
continue;
Expand All @@ -151,9 +153,9 @@ public function scan(): int {
}
}

$preview->setStorageId($result[0]['storage']);
$preview->setEtag($result[0]['etag']);
$preview->setSourceMimetype($result[0]['mimetype']);
$preview->setStorageId($result['storage']);
$preview->setEtag($result['etag']);
$preview->setSourceMimetype($this->mimeTypeLoader->getMimetypeById($result['mimetype']));
$preview->generateId();
// try to insert, if that fails the preview is already in the DB
$this->previewMapper->insert($preview);
Expand Down
Loading