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 bool is_unknown() {return false;}
protected:
/// The MIME type handled by the filter.
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;
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;

View File

@ -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_ */

View File

@ -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;