From 0840daf20ee9b43c261ade2a2e418cfccb13c755 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Thu, 6 Aug 2015 08:08:36 +0200 Subject: [PATCH] Avoid replacing (instead of concatenating) the current author field value with the internal one when the document is a top-level one. This allows metadata from metadatacmds to be used --- src/internfile/internfile.cpp | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/internfile/internfile.cpp b/src/internfile/internfile.cpp index e34168cb..6a652181 100644 --- a/src/internfile/internfile.cpp +++ b/src/internfile/internfile.cpp @@ -28,9 +28,8 @@ #include #include #include -#ifndef NO_NAMESPACES + using namespace std; -#endif /* NO_NAMESPACES */ #include "cstr.h" #include "internfile.h" @@ -550,6 +549,10 @@ bool FileInterner::dijontorcl(Rcl::Doc& doc) // doc with an ipath, not the last one which is usually text/plain We // also set the author and modification time from the last doc which // has them. +// +// The stack can contain objects with an ipath element (corresponding +// to actual embedded documents), and, at the top, elements without an +// ipath element, corresponding to format translations of the last doc. // // The docsize is fetched from the first element without an ipath // (first non container). If the last element directly returns @@ -579,7 +582,8 @@ void FileInterner::collectIpathAndMT(Rcl::Doc& doc) const const map& docdata = (*hit)->get_meta_data(); if (getKeyValue(docdata, cstr_dj_keyipath, ipathel)) { if (!ipathel.empty()) { - // We have a non-empty ipath + // 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]); @@ -593,8 +597,18 @@ void FileInterner::collectIpathAndMT(Rcl::Doc& doc) const getKeyValue(docdata, cstr_dj_keydocsize, doc.fbytes); doc.ipath += cstr_isep; } - getKeyValue(docdata, cstr_dj_keyauthor, doc.meta[Rcl::Doc::keyau]); - getKeyValue(docdata, cstr_dj_keymd, doc.dmtime); + // 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 + // actually embedded documents (avoid replacing values from + // metacmds for the topmost one). For a topmost doc, author + // will be merged by dijontorcl() later on. About same for + // dmtime, but an external value will be replaced, not + // augmented if dijontorcl() finds an internal value. + if (hasipath) { + getKeyValue(docdata, cstr_dj_keyauthor, doc.meta[Rcl::Doc::keyau]); + getKeyValue(docdata, cstr_dj_keymd, doc.dmtime); + } } // Trim empty tail elements in ipath. @@ -878,12 +892,6 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath return FIAgain; } -// Temporary while we fix backend things -static string urltolocalpath(string url) -{ - return url.substr(7, string::npos); -} - bool FileInterner::tempFileForMT(TempFile& otemp, RclConfig* cnf, const string& mimetype) {