From 01d0f4b73411f2701b943af48edd0d92f60a888d Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Fri, 12 Aug 2016 18:00:52 +0200 Subject: [PATCH] execm filters: the change to let filters set arbitrary metadata lost the top doc size, now saved aside --- src/common/cstr.h | 1 - src/internfile/internfile.cpp | 38 +++++++++++++++++------------------ src/internfile/mimehandler.h | 9 ++++++--- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/common/cstr.h b/src/common/cstr.h index c3c55ca1..7f41099b 100644 --- a/src/common/cstr.h +++ b/src/common/cstr.h @@ -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_ */ diff --git a/src/internfile/internfile.cpp b/src/internfile/internfile.cpp index 8037adf5..37cf8c5a 100644 --- a/src/internfile/internfile.cpp +++ b/src/internfile/internfile.cpp @@ -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::const_iterator hit = m_handlers.begin(); hit != m_handlers.end(); hit++) { const map& 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 diff --git a/src/internfile/mimehandler.h b/src/internfile/mimehandler.h index 97257a17..fa03cecf 100644 --- a/src/internfile/mimehandler.h +++ b/src/internfile/mimehandler.h @@ -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 }; /**