Skip to content

Commit 7b86624

Browse files
committed
fix(TaskProcessing): Fallback to getMimeType()
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
1 parent 784f76d commit 7b86624

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

core/Controller/TaskProcessingApiController.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -409,12 +409,16 @@ private function getFileContentsInternal(Task $task, int $fileId): StreamRespons
409409

410410
$contentType = $node->getMimeType();
411411
if (function_exists('mime_content_type')) {
412-
$mimeType = mime_content_type($node->fopen('rb'));
413-
if ($mimeType !== false) {
414-
$mimeType = $this->mimeTypeDetector->getSecureMimeType($mimeType);
415-
if ($mimeType !== 'application/octet-stream') {
416-
$contentType = $mimeType;
412+
try {
413+
$mimeType = mime_content_type($node->fopen('rb'));
414+
if ($mimeType !== false) {
415+
$mimeType = $this->mimeTypeDetector->getSecureMimeType($mimeType);
416+
if ($mimeType !== 'application/octet-stream') {
417+
$contentType = $mimeType;
418+
}
417419
}
420+
} catch (\Throwable $e) {
421+
\OCP\Server::get(LoggerInterface::class)->info('mime_content_type() failed to open node, falling back to getMimeType()', ['exception' => $e]);
418422
}
419423
}
420424

0 commit comments

Comments
 (0)