execm filters: the change to let filters set arbitrary metadata lost the top doc size, now saved aside

This commit is contained in:
Jean-Francois Dockes 2016-08-12 18:00:52 +02:00
parent 3bbaf51b5f
commit 01d0f4b734
3 changed files with 24 additions and 24 deletions

View file

@ -80,7 +80,6 @@ DEF_CSTR(dj_keycontent, "content");
DEF_CSTR(dj_keyipath, "ipath");
DEF_CSTR(dj_keymd5, "md5");
DEF_CSTR(dj_keymt, "mimetype");
DEF_CSTR(dj_keydocsize, "docsize");
DEF_CSTR(dj_keyanc, "rclanc");
#endif /* _CSTR_H_INCLUDED_ */

View file

@ -517,9 +517,9 @@ bool FileInterner::dijontorcl(Rcl::Doc& doc)
// point if the last container filter is directly
// returning text/plain content, so that there is no
// ipath-less filter at the top
char cbuf[30];
sprintf(cbuf, "%d", int(doc.text.length()));
doc.fbytes = cbuf;
lltodecstr(doc.text.length(), doc.fbytes);
LOGDEB("FileInterner::dijontorcl: fbytes->" << doc.fbytes <<
endl);
}
} else if (it->first == cstr_dj_keymd) {
doc.dmtime = it->second;
@ -584,23 +584,21 @@ void FileInterner::collectIpathAndMT(Rcl::Doc& doc) const
for (vector<RecollFilter*>::const_iterator hit = m_handlers.begin();
hit != m_handlers.end(); hit++) {
const map<string, string>& docdata = (*hit)->get_meta_data();
if (getKeyValue(docdata, cstr_dj_keyipath, ipathel)) {
if (!ipathel.empty()) {
// Non-empty ipath. This stack element is for an
// actual embedded document, not a format translation.
hasipath = true;
getKeyValue(docdata, cstr_dj_keymt, doc.mimetype);
getKeyValue(docdata, cstr_dj_keyfn, doc.meta[Rcl::Doc::keyfn]);
} else {
if (doc.fbytes.empty())
getKeyValue(docdata, cstr_dj_keydocsize, doc.fbytes);
}
doc.ipath += colon_hide(ipathel) + cstr_isep;
} else {
if (doc.fbytes.empty())
getKeyValue(docdata, cstr_dj_keydocsize, doc.fbytes);
doc.ipath += cstr_isep;
}
ipathel.clear();
getKeyValue(docdata, cstr_dj_keyipath, ipathel);
if (!ipathel.empty()) {
// Non-empty ipath. This stack element is for an
// actual embedded document, not a format translation.
hasipath = true;
getKeyValue(docdata, cstr_dj_keymt, doc.mimetype);
getKeyValue(docdata, cstr_dj_keyfn, doc.meta[Rcl::Doc::keyfn]);
} else {
if (doc.fbytes.empty()) {
lltodecstr((*hit)->get_docsize(), doc.fbytes);
LOGDEB("collectIpath..: fbytes->" << doc.fbytes << endl);
}
}
doc.ipath += colon_hide(ipathel) + cstr_isep;
// We set the author field from the innermost doc which has
// one: allows finding, e.g. an image attachment having no
// metadata by a search on the sender name. Only do this for

View file

@ -92,9 +92,11 @@ public:
return set_document_string(mtype, std::string(cp, sz));
}
virtual void set_docsize(off_t size)
{
m_metaData[cstr_dj_keydocsize] = ulltodecstr(size);
virtual void set_docsize(off_t size) {
m_docsize = size;
}
virtual off_t get_docsize() const {
return m_docsize;
}
virtual bool has_documents() const {return m_havedoc;}
@ -146,6 +148,7 @@ protected:
// m_id is and md5 of the filter definition line (from mimeconf) and
// is used when fetching/returning filters to / from the cache.
std::string m_id;
off_t m_docsize; // Size of the top document
};
/**