mirror of
https://github.com/nextcloud/server.git
synced 2026-04-03 16:16:36 -04:00
fix: handle null mime type in preview generation gracefully
This commit is contained in:
parent
ed1b0dcd5e
commit
17cbda960f
1 changed files with 11 additions and 2 deletions
|
|
@ -400,7 +400,12 @@ class Generator {
|
|||
$previewEntry->setMax($max);
|
||||
$previewEntry->setCropped($crop);
|
||||
$previewEntry->setEncrypted(false);
|
||||
$previewEntry->setMimetype($preview->dataMimeType());
|
||||
$previewMimeType = $preview->dataMimeType();
|
||||
if ($previewMimeType === null) {
|
||||
$this->logger->warning('Preview provider returned null MIME type for {path}, skipping provider.', ['path' => $file->getPath()]);
|
||||
continue;
|
||||
}
|
||||
$previewEntry->setMimetype($previewMimeType);
|
||||
$previewEntry->setEtag($file->getEtag());
|
||||
$previewEntry->setMtime((new \DateTime())->getTimestamp());
|
||||
return $this->savePreview($previewEntry, $preview);
|
||||
|
|
@ -554,7 +559,11 @@ class Generator {
|
|||
$previewEntry->setMax(false);
|
||||
$previewEntry->setCropped($crop);
|
||||
$previewEntry->setEncrypted(false);
|
||||
$previewEntry->setMimeType($preview->dataMimeType());
|
||||
$previewMimeType = $preview->dataMimeType();
|
||||
if ($previewMimeType === null) {
|
||||
throw new NotFoundException('Generated preview has no MIME type for file ' . $file->getPath());
|
||||
}
|
||||
$previewEntry->setMimeType($previewMimeType);
|
||||
$previewEntry->setEtag($file->getEtag());
|
||||
$previewEntry->setMtime((new \DateTime())->getTimestamp());
|
||||
if ($cacheResult) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue