summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2015-12-06 16:00:18 +0100
committerSlávek Banko <slavek.banko@axis.cz>2015-12-06 16:03:57 +0100
commita054c133c7e47908249ce1c30224f529ed0a9340 (patch)
tree01b3a42a6637c67c7bb9ffa1bfd4cada8529de58
parent43b1218e15df31194d70161e058032582afbef83 (diff)
downloadtdelibs-a054c133c7e47908249ce1c30224f529ed0a9340.tar.gz
tdelibs-a054c133c7e47908249ce1c30224f529ed0a9340.zip
Fix mimetype detection using magic library
for mime types not contained in TDE settings This resolves Bug 2392 Signed-off-by: Slávek Banko <slavek.banko@axis.cz> (cherry picked from commit b0ac7d287922e883a2e571222089b680adfe46c6)
-rw-r--r--mimetypes/application/octet-stream.desktop1
-rw-r--r--tdeio/tdeio/kmimetype.cpp8
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;
+ }
+ }
}
}