Switch to unified view

a/src/internfile/internfile.cpp b/src/internfile/internfile.cpp
...
...
579
// be cleaned up as the "inheritance" rules inside the stack are
579
// be cleaned up as the "inheritance" rules inside the stack are
580
// actually complicated.
580
// actually complicated.
581
void FileInterner::collectIpathAndMT(Rcl::Doc& doc) const
581
void FileInterner::collectIpathAndMT(Rcl::Doc& doc) const
582
{
582
{
583
    LOGDEB2("FileInterner::collectIpathAndMT\n");
583
    LOGDEB2("FileInterner::collectIpathAndMT\n");
584
585
    // Set to true if any element in the stack sets an ipath. (at least one of
586
    // the docs is a compound).
584
    bool hasipath = false;
587
    bool hasipath = false;
585
588
586
    if (!m_noxattrs) {
589
    if (!m_noxattrs) {
587
    docFieldsFromXattrs(m_cfg, m_XAttrsFields, doc);
590
    docFieldsFromXattrs(m_cfg, m_XAttrsFields, doc);
588
    }
591
    }
589
592
590
    docFieldsFromMetaCmds(m_cfg, m_cmdFields, doc);
593
    docFieldsFromMetaCmds(m_cfg, m_cmdFields, doc);
591
594
592
    // If there is no ipath stack, the mimetype is the one from the file
595
    // If there is no ipath stack, the mimetype is the one from the
596
    // file, else we'll change it further down.
593
    doc.mimetype = m_mimetype;
597
    doc.mimetype = m_mimetype;
594
598
595
    string ipathel;
599
    for (const auto& handler : m_handlers) {
596
    for (vector<RecollFilter*>::const_iterator hit = m_handlers.begin();
597
   hit != m_handlers.end(); hit++) {
598
    const map<string, string>& docdata = (*hit)->get_meta_data();
600
    const map<string, string>& docdata = handler->get_meta_data();
599
        ipathel.clear();
601
        string ipathel;
600
    getKeyValue(docdata, cstr_dj_keyipath, ipathel);
602
    getKeyValue(docdata, cstr_dj_keyipath, ipathel);
601
        if (!ipathel.empty()) {
603
        if (!ipathel.empty()) {
602
            // Non-empty ipath. This stack element is for an
604
            // Non-empty ipath. This stack element is for an
603
            // actual embedded document, not a format translation.
605
            // actual embedded document, not a format translation.
604
            hasipath = true;
606
            hasipath = true;
607
            doc.ipath += colon_hide(ipathel) + cstr_isep;
605
            getKeyValue(docdata, cstr_dj_keymt, doc.mimetype);
608
            getKeyValue(docdata, cstr_dj_keymt, doc.mimetype);
606
            getKeyValue(docdata, cstr_dj_keyfn, doc.meta[Rcl::Doc::keyfn]);
609
            getKeyValue(docdata, cstr_dj_keyfn, doc.meta[Rcl::Doc::keyfn]);
607
        } else {
610
       } else {
608
            if (doc.fbytes.empty()) {
611
            if (doc.fbytes.empty()) {
609
                lltodecstr((*hit)->get_docsize(), doc.fbytes);
612
                lltodecstr(handler->get_docsize(), doc.fbytes);
610
                LOGDEB("collectIpath..: fbytes->" << doc.fbytes << endl);
613
                LOGDEB("collectIpath..: fbytes->" << doc.fbytes << endl);
611
            }
614
            }
612
        }
615
        }
613
        doc.ipath += colon_hide(ipathel) + cstr_isep;
614
        // We set the author field from the innermost doc which has
616
        // We set the author field from the innermost doc which has
615
        // one: allows finding, e.g. an image attachment having no
617
        // one: allows finding, e.g. an image attachment having no
616
        // metadata by a search on the sender name. Only do this for
618
        // metadata by a search on the sender name. Only do this for
617
        // actually embedded documents (avoid replacing values from
619
        // actually embedded documents (avoid replacing values from
618
        // metacmds for the topmost one). For a topmost doc, author
620
        // metacmds for the topmost one). For a topmost doc, author
...
...
623
            getKeyValue(docdata, cstr_dj_keyauthor, doc.meta[Rcl::Doc::keyau]);
625
            getKeyValue(docdata, cstr_dj_keyauthor, doc.meta[Rcl::Doc::keyau]);
624
            getKeyValue(docdata, cstr_dj_keymd, doc.dmtime);
626
            getKeyValue(docdata, cstr_dj_keymd, doc.dmtime);
625
        }
627
        }
626
    }
628
    }
627
629
628
    // Trim empty tail elements in ipath.
629
    if (hasipath) {
630
    if (hasipath) {
631
        // Trim ending ipath separator
630
    LOGDEB2("IPATH [" << doc.ipath << "]\n");
632
    LOGDEB2("IPATH [" << doc.ipath << "]\n");
631
  string::size_type sit = doc.ipath.find_last_not_of(cstr_isep);
633
        if (doc.ipath.back() ==  cstr_isep[0]) {
632
  if (sit == string::npos)
634
            doc.ipath.erase(doc.ipath.end()-1);
633
      doc.ipath.erase();
635
        }
634
  else if (sit < doc.ipath.length() -1)
635
      doc.ipath.erase(sit+1);
636
    } else {
637
  doc.ipath.erase();
638
    }
636
    }
639
}
637
}
640
638
641
// Remove handler from stack. Clean up temp file if needed.
639
// Remove handler from stack. Clean up temp file if needed.
642
void FileInterner::popHandler()
640
void FileInterner::popHandler()