Skip to content

Commit 8557f66

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

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

core/Controller/TaskProcessingApiController.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
use OCP\TaskProcessing\IManager;
4040
use OCP\TaskProcessing\ShapeEnumValue;
4141
use OCP\TaskProcessing\Task;
42+
use Psr\Log\LoggerInterface;
4243
use RuntimeException;
4344
use stdClass;
4445

@@ -409,12 +410,16 @@ private function getFileContentsInternal(Task $task, int $fileId): StreamRespons
409410

410411
$contentType = $node->getMimeType();
411412
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;
413+
try {
414+
$mimeType = mime_content_type($node->fopen('rb'));
415+
if ($mimeType !== false) {
416+
$mimeType = $this->mimeTypeDetector->getSecureMimeType($mimeType);
417+
if ($mimeType !== 'application/octet-stream') {
418+
$contentType = $mimeType;
419+
}
417420
}
421+
} catch (\Throwable $e) {
422+
\OCP\Server::get(LoggerInterface::class)->info('mime_content_type() failed to open node, falling back to getMimeType()', ['exception' => $e]);
418423
}
419424
}
420425

0 commit comments

Comments
 (0)