Switch to unified view

a/src/internfile/internfile.cpp b/src/internfile/internfile.cpp
...
...
608
// While we're at it, we also set the mimetype and filename, which are special 
608
// While we're at it, we also set the mimetype and filename, which are special 
609
// properties: we want to get them from the topmost doc
609
// properties: we want to get them from the topmost doc
610
// with an ipath, not the last one which is usually text/plain
610
// with an ipath, not the last one which is usually text/plain
611
// We also set the author and modification time from the last doc
611
// We also set the author and modification time from the last doc
612
// which has them.
612
// which has them.
613
void FileInterner::collectIpathAndMT(Rcl::Doc& doc, string& ipath) const
613
void FileInterner::collectIpathAndMT(Rcl::Doc& doc) const
614
{
614
{
615
    LOGDEB2(("FileInterner::collectIpathAndMT\n"));
615
    LOGDEB2(("FileInterner::collectIpathAndMT\n"));
616
    bool hasipath = false;
616
    bool hasipath = false;
617
617
618
#ifdef RCL_USE_XATTR
618
#ifdef RCL_USE_XATTR
...
...
636
        // We have a non-empty ipath
636
        // We have a non-empty ipath
637
        hasipath = true;
637
        hasipath = true;
638
        getKeyValue(docdata, keymt, doc.mimetype);
638
        getKeyValue(docdata, keymt, doc.mimetype);
639
        getKeyValue(docdata, keyfn, doc.utf8fn);
639
        getKeyValue(docdata, keyfn, doc.utf8fn);
640
        }
640
        }
641
        ipath += colon_hide(ipathel) + isep;
641
        doc.ipath += colon_hide(ipathel) + isep;
642
    } else {
642
    } else {
643
        ipath += isep;
643
        doc.ipath += isep;
644
    }
644
    }
645
    getKeyValue(docdata, keyau, doc.meta[Rcl::Doc::keyau]);
645
    getKeyValue(docdata, keyau, doc.meta[Rcl::Doc::keyau]);
646
    getKeyValue(docdata, keymd, doc.dmtime);
646
    getKeyValue(docdata, keymd, doc.dmtime);
647
    }
647
    }
648
648
649
    // Trim empty tail elements in ipath.
649
    // Trim empty tail elements in ipath.
650
    if (hasipath) {
650
    if (hasipath) {
651
    LOGDEB2(("IPATH [%s]\n", ipath.c_str()));
651
    LOGDEB2(("IPATH [%s]\n", doc.ipath.c_str()));
652
    string::size_type sit = ipath.find_last_not_of(isep);
652
    string::size_type sit = doc.ipath.find_last_not_of(isep);
653
    if (sit == string::npos)
653
    if (sit == string::npos)
654
        ipath.erase();
654
        doc.ipath.erase();
655
    else if (sit < ipath.length() -1)
655
    else if (sit < doc.ipath.length() -1)
656
        ipath.erase(sit+1);
656
        doc.ipath.erase(sit+1);
657
    } else {
657
    } else {
658
    ipath.erase();
658
    doc.ipath.erase();
659
    }
659
    }
660
}
660
}
661
661
662
// Remove handler from stack. Clean up temp file if needed.
662
// Remove handler from stack. Clean up temp file if needed.
663
void FileInterner::popHandler()
663
void FileInterner::popHandler()
...
...
761
    LOGDEB1(("FileInterner::addHandler: added\n"));
761
    LOGDEB1(("FileInterner::addHandler: added\n"));
762
    return ADD_OK;
762
    return ADD_OK;
763
}
763
}
764
764
765
// Information and debug after a next_document error
765
// Information and debug after a next_document error
766
void FileInterner::processNextDocError(Rcl::Doc &doc, string& ipath)
766
void FileInterner::processNextDocError(Rcl::Doc &doc)
767
{
767
{
768
    collectIpathAndMT(doc, ipath);
768
    collectIpathAndMT(doc);
769
    m_reason = m_handlers.back()->get_error();
769
    m_reason = m_handlers.back()->get_error();
770
    checkExternalMissing(m_reason, doc.mimetype);
770
    checkExternalMissing(m_reason, doc.mimetype);
771
    LOGERR(("FileInterner::internfile: next_document error "
771
    LOGERR(("FileInterner::internfile: next_document error "
772
        "[%s%s%s] %s %s\n", m_fn.c_str(), ipath.empty() ? "" : "|", 
772
        "[%s%s%s] %s %s\n", m_fn.c_str(), doc.ipath.empty() ? "" : "|", 
773
        ipath.c_str(), doc.mimetype.c_str(), m_reason.c_str()));
773
        doc.ipath.c_str(), doc.mimetype.c_str(), m_reason.c_str()));
774
}
774
}
775
775
776
FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath)
776
FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath)
777
{
777
{
778
    LOGDEB(("FileInterner::internfile. ipath [%s]\n", ipath.c_str()));
778
    LOGDEB(("FileInterner::internfile. ipath [%s]\n", ipath.c_str()));
...
...
839
839
840
    // While indexing, don't stop on next_document() error. There
840
    // While indexing, don't stop on next_document() error. There
841
    // might be ie an error while decoding an attachment, but we
841
    // might be ie an error while decoding an attachment, but we
842
    // still want to process the rest of the mbox! For preview: fatal.
842
    // still want to process the rest of the mbox! For preview: fatal.
843
    if (!m_handlers.back()->next_document()) {
843
    if (!m_handlers.back()->next_document()) {
844
      string oipath;
845
        processNextDocError(doc, oipath);
844
        processNextDocError(doc);
846
        if (m_forPreview) {
845
        if (m_forPreview) {
847
                m_reason += "Requested document does not exist. ";
846
                m_reason += "Requested document does not exist. ";
848
                m_reason += m_handlers.back()->get_error();
847
                m_reason += m_handlers.back()->get_error();
849
                LOGERR(("FileInterner: requested document does not exist\n"));
848
                LOGERR(("FileInterner: requested document does not exist\n"));
850
        return FIError;
849
        return FIError;
...
...
900
    // fields from the ancesters (like date or author). This is useful
899
    // fields from the ancesters (like date or author). This is useful
901
    // for email attachments. The values will be replaced by those
900
    // for email attachments. The values will be replaced by those
902
    // internal to the document (by dijontorcl()) if any, so the order
901
    // internal to the document (by dijontorcl()) if any, so the order
903
    // of calls is important.
902
    // of calls is important.
904
    if (!m_forPreview) {
903
    if (!m_forPreview) {
905
    collectIpathAndMT(doc, doc.ipath);
904
    collectIpathAndMT(doc);
906
    } else {
905
    } else {
907
    doc.mimetype = m_reachedMType;
906
    doc.mimetype = m_reachedMType;
908
    }
907
    }
909
    // Keep this AFTER collectIpathAndMT
908
    // Keep this AFTER collectIpathAndMT
910
    dijontorcl(doc);
909
    dijontorcl(doc);