From 52e845a9fbd860f880e9cf7e8db8e93490b1689b Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Tue, 14 Dec 2010 18:21:39 +0100 Subject: [PATCH] debug traces: add is_unknown() method to filters to help with pointing out unhandled mime types --- src/internfile/Filter.h | 2 +- src/internfile/internfile.cpp | 5 ++--- src/internfile/mh_unknown.h | 4 +--- src/internfile/mimehandler.cpp | 6 +++++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/internfile/Filter.h b/src/internfile/Filter.h index be1e897f..e69eeb5d 100644 --- a/src/internfile/Filter.h +++ b/src/internfile/Filter.h @@ -165,7 +165,7 @@ namespace Dijon } virtual void clear() {m_metaData.clear();} - + virtual bool is_unknown() {return false;} protected: /// The MIME type handled by the filter. std::string m_mimeType; diff --git a/src/internfile/internfile.cpp b/src/internfile/internfile.cpp index 92805367..c7eaf2e2 100644 --- a/src/internfile/internfile.cpp +++ b/src/internfile/internfile.cpp @@ -254,9 +254,8 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf, m_mimetype = l_mime; Dijon::Filter *df = getMimeHandler(l_mime, m_cfg, !m_forPreview); - if (!df) { - // No handler for this type, for now :( if indexallfilenames - // is set in the config, this normally wont happen (we get mh_unknown) + if (!df or df->is_unknown()) { + // No real handler for this type, for now :( LOGINFO(("FileInterner:: ignored: [%s] mime [%s]\n", f.c_str(), l_mime.c_str())); return; diff --git a/src/internfile/mh_unknown.h b/src/internfile/mh_unknown.h index ade9e981..5e068952 100644 --- a/src/internfile/mh_unknown.h +++ b/src/internfile/mh_unknown.h @@ -45,9 +45,7 @@ class MimeHandlerUnknown : public RecollFilter { m_metaData["mimetype"] = "text/plain"; return true; } - virtual void clear() { - RecollFilter::clear(); - } + virtual bool is_unknown() {return true;} }; #endif /* _MH_UNKNOWN_H_INCLUDED_ */ diff --git a/src/internfile/mimehandler.cpp b/src/internfile/mimehandler.cpp index 4f92624b..ce47442b 100644 --- a/src/internfile/mimehandler.cpp +++ b/src/internfile/mimehandler.cpp @@ -71,6 +71,11 @@ static Dijon::Filter *mhFactory(const string &mime) // exec) but still opening with a specific editor. return new MimeHandlerText(lmime); } else { + // We should not get there. It means that "internal" was set + // as a handler in mimeconf for a mime type we actually can't + // handle. + LOGERR(("mhFactory: mime type [%s] set as internal but unknown\n", + lmime.c_str())); return new MimeHandlerUnknown(lmime); } } @@ -222,7 +227,6 @@ Dijon::Filter *getMimeHandler(const string &mtype, RclConfig *cfg, bool indexunknown = false; cfg->getConfParam("indexallfilenames", &indexunknown); if (indexunknown) { - LOGDEB(("getMimeHandler: returning MimeHandlerUnknown\n")); return new MimeHandlerUnknown("application/octet-stream"); } else { return 0;