From ad46a6344885237beb2d4b10d878a3836ea2f296 Mon Sep 17 00:00:00 2001 From: rtoth Date: Mon, 28 Feb 2022 14:47:10 +0000 Subject: [PATCH] Add patch from Julius "Make sure to properly set the mimetype if the detection has a different one" --- apps/dav/lib/Connector/Sabre/File.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php index a7cafeb4a5e1a..f62ab3cd73614 100644 --- a/apps/dav/lib/Connector/Sabre/File.php +++ b/apps/dav/lib/Connector/Sabre/File.php @@ -556,6 +556,15 @@ public function delete() { public function getContentType() { $mimeType = $this->info->getMimetype(); + if ($mimeType === 'application/octet-stream') { + $mimeType = \OC::$server->getMimeTypeDetector()->detectPath($this->info->getInternalPath()); + if ($this->info->getMimetype() !== $mimeType) { + $this->info->getStorage()->getCache()->update($this->info->getId(), [ + 'mimetype' => $mimeType + ]); + } + } + // PROPFIND needs to return the correct mime type, for consistency with the web UI if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PROPFIND') { return $mimeType;