internfile:collectIpathAndMT: simplify a bit
This commit is contained in:
parent
7b9fc3dda1
commit
23141307f7
@ -581,6 +581,9 @@ bool FileInterner::dijontorcl(Rcl::Doc& doc)
|
|||||||
void FileInterner::collectIpathAndMT(Rcl::Doc& doc) const
|
void FileInterner::collectIpathAndMT(Rcl::Doc& doc) const
|
||||||
{
|
{
|
||||||
LOGDEB2("FileInterner::collectIpathAndMT\n");
|
LOGDEB2("FileInterner::collectIpathAndMT\n");
|
||||||
|
|
||||||
|
// Set to true if any element in the stack sets an ipath. (at least one of
|
||||||
|
// the docs is a compound).
|
||||||
bool hasipath = false;
|
bool hasipath = false;
|
||||||
|
|
||||||
if (!m_noxattrs) {
|
if (!m_noxattrs) {
|
||||||
@ -589,28 +592,27 @@ void FileInterner::collectIpathAndMT(Rcl::Doc& doc) const
|
|||||||
|
|
||||||
docFieldsFromMetaCmds(m_cfg, m_cmdFields, doc);
|
docFieldsFromMetaCmds(m_cfg, m_cmdFields, doc);
|
||||||
|
|
||||||
// If there is no ipath stack, the mimetype is the one from the file
|
// If there is no ipath stack, the mimetype is the one from the
|
||||||
|
// file, else we'll change it further down.
|
||||||
doc.mimetype = m_mimetype;
|
doc.mimetype = m_mimetype;
|
||||||
|
|
||||||
string ipathel;
|
for (const auto& handler : m_handlers) {
|
||||||
for (vector<RecollFilter*>::const_iterator hit = m_handlers.begin();
|
const map<string, string>& docdata = handler->get_meta_data();
|
||||||
hit != m_handlers.end(); hit++) {
|
string ipathel;
|
||||||
const map<string, string>& docdata = (*hit)->get_meta_data();
|
|
||||||
ipathel.clear();
|
|
||||||
getKeyValue(docdata, cstr_dj_keyipath, ipathel);
|
getKeyValue(docdata, cstr_dj_keyipath, ipathel);
|
||||||
if (!ipathel.empty()) {
|
if (!ipathel.empty()) {
|
||||||
// Non-empty ipath. This stack element is for an
|
// Non-empty ipath. This stack element is for an
|
||||||
// actual embedded document, not a format translation.
|
// actual embedded document, not a format translation.
|
||||||
hasipath = true;
|
hasipath = true;
|
||||||
|
doc.ipath += colon_hide(ipathel) + cstr_isep;
|
||||||
getKeyValue(docdata, cstr_dj_keymt, doc.mimetype);
|
getKeyValue(docdata, cstr_dj_keymt, doc.mimetype);
|
||||||
getKeyValue(docdata, cstr_dj_keyfn, doc.meta[Rcl::Doc::keyfn]);
|
getKeyValue(docdata, cstr_dj_keyfn, doc.meta[Rcl::Doc::keyfn]);
|
||||||
} else {
|
} else {
|
||||||
if (doc.fbytes.empty()) {
|
if (doc.fbytes.empty()) {
|
||||||
lltodecstr((*hit)->get_docsize(), doc.fbytes);
|
lltodecstr(handler->get_docsize(), doc.fbytes);
|
||||||
LOGDEB("collectIpath..: fbytes->" << doc.fbytes << endl);
|
LOGDEB("collectIpath..: fbytes->" << doc.fbytes << endl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
doc.ipath += colon_hide(ipathel) + cstr_isep;
|
|
||||||
// We set the author field from the innermost doc which has
|
// We set the author field from the innermost doc which has
|
||||||
// one: allows finding, e.g. an image attachment having no
|
// one: allows finding, e.g. an image attachment having no
|
||||||
// metadata by a search on the sender name. Only do this for
|
// metadata by a search on the sender name. Only do this for
|
||||||
@ -625,16 +627,12 @@ void FileInterner::collectIpathAndMT(Rcl::Doc& doc) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trim empty tail elements in ipath.
|
|
||||||
if (hasipath) {
|
if (hasipath) {
|
||||||
|
// Trim ending ipath separator
|
||||||
LOGDEB2("IPATH [" << doc.ipath << "]\n");
|
LOGDEB2("IPATH [" << doc.ipath << "]\n");
|
||||||
string::size_type sit = doc.ipath.find_last_not_of(cstr_isep);
|
if (doc.ipath.back() == cstr_isep[0]) {
|
||||||
if (sit == string::npos)
|
doc.ipath.erase(doc.ipath.end()-1);
|
||||||
doc.ipath.erase();
|
}
|
||||||
else if (sit < doc.ipath.length() -1)
|
|
||||||
doc.ipath.erase(sit+1);
|
|
||||||
} else {
|
|
||||||
doc.ipath.erase();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user