From b0ac7d287922e883a2e571222089b680adfe46c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Sun, 6 Dec 2015 16:00:18 +0100 Subject: [PATCH] Fix mimetype detection using magic library for mime types not contained in TDE settings This resolves Bug 2392 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko --- mimetypes/application/octet-stream.desktop | 1 + tdeio/tdeio/kmimetype.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mimetypes/application/octet-stream.desktop b/mimetypes/application/octet-stream.desktop index 3b2859890..72a60bc3b 100644 --- a/mimetypes/application/octet-stream.desktop +++ b/mimetypes/application/octet-stream.desktop @@ -1,6 +1,7 @@ [Desktop Entry] Type=MimeType MimeType=application/octet-stream +X-TDE-PatternsAccuracy=0 Comment=Unknown Comment[af]=Onbekende Comment[ar]=غير معروف diff --git a/tdeio/tdeio/kmimetype.cpp b/tdeio/tdeio/kmimetype.cpp index d1bd940eb..197670916 100644 --- a/tdeio/tdeio/kmimetype.cpp +++ b/tdeio/tdeio/kmimetype.cpp @@ -221,8 +221,12 @@ KMimeType::Ptr KMimeType::findByURL( const KURL& _url, mode_t _mode, KMimeMagicResult* result = KMimeMagic::self()->findFileType( path ); - if ( result && result->isValid() && result->accuracy() > 0 ) - return mimeType( result->mimeType() ); + if ( result && result->isValid() && result->accuracy() > 0 ) { + KMimeType::Ptr resultMime = mimeType( result->mimeType() ); + if (resultMime->patternsAccuracy() > 0) { + return resultMime; + } + } } }