debug traces: add is_unknown() method to filters to help with pointing out unhandled mime types

This commit is contained in:
Jean-Francois Dockes 2010-12-14 18:21:39 +01:00
parent 7c14a06eb1
commit 52e845a9fb
4 changed files with 9 additions and 8 deletions

View File

@ -165,7 +165,7 @@ namespace Dijon
} }
virtual void clear() {m_metaData.clear();} virtual void clear() {m_metaData.clear();}
virtual bool is_unknown() {return false;}
protected: protected:
/// The MIME type handled by the filter. /// The MIME type handled by the filter.
std::string m_mimeType; std::string m_mimeType;

View File

@ -254,9 +254,8 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
m_mimetype = l_mime; m_mimetype = l_mime;
Dijon::Filter *df = getMimeHandler(l_mime, m_cfg, !m_forPreview); Dijon::Filter *df = getMimeHandler(l_mime, m_cfg, !m_forPreview);
if (!df) { if (!df or df->is_unknown()) {
// No handler for this type, for now :( if indexallfilenames // No real handler for this type, for now :(
// is set in the config, this normally wont happen (we get mh_unknown)
LOGINFO(("FileInterner:: ignored: [%s] mime [%s]\n", LOGINFO(("FileInterner:: ignored: [%s] mime [%s]\n",
f.c_str(), l_mime.c_str())); f.c_str(), l_mime.c_str()));
return; return;

View File

@ -45,9 +45,7 @@ class MimeHandlerUnknown : public RecollFilter {
m_metaData["mimetype"] = "text/plain"; m_metaData["mimetype"] = "text/plain";
return true; return true;
} }
virtual void clear() { virtual bool is_unknown() {return true;}
RecollFilter::clear();
}
}; };
#endif /* _MH_UNKNOWN_H_INCLUDED_ */ #endif /* _MH_UNKNOWN_H_INCLUDED_ */

View File

@ -71,6 +71,11 @@ static Dijon::Filter *mhFactory(const string &mime)
// exec) but still opening with a specific editor. // exec) but still opening with a specific editor.
return new MimeHandlerText(lmime); return new MimeHandlerText(lmime);
} else { } 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); return new MimeHandlerUnknown(lmime);
} }
} }
@ -222,7 +227,6 @@ Dijon::Filter *getMimeHandler(const string &mtype, RclConfig *cfg,
bool indexunknown = false; bool indexunknown = false;
cfg->getConfParam("indexallfilenames", &indexunknown); cfg->getConfParam("indexallfilenames", &indexunknown);
if (indexunknown) { if (indexunknown) {
LOGDEB(("getMimeHandler: returning MimeHandlerUnknown\n"));
return new MimeHandlerUnknown("application/octet-stream"); return new MimeHandlerUnknown("application/octet-stream");
} else { } else {
return 0; return 0;