diff --git a/src/doc/user/usermanual.sgml b/src/doc/user/usermanual.sgml index 8282251b..796b2e59 100644 --- a/src/doc/user/usermanual.sgml +++ b/src/doc/user/usermanual.sgml @@ -3204,11 +3204,14 @@ skippedPaths = ~/somedir/∗.txt localfields - This allows setting fields for all documents - under a given directory. Typical usage would be to set an - "rclaptg" field, to be used in mimeview to - select a specific viewer. Ie: - localfields=rclaptg=gnus;other=val, then + This allows setting fields for all + documents under a given directory. Typical usage would be + to set an "rclaptg" field, to be used in + mimeview to select a specific + viewer. If several fields are to be set, they should be + separated with a ':' character (which there is currently no way to + escape). Ie: + localfields= rclaptg=gnus:other = val, then select specifier viewer with mimetype|tag=... in mimeview. diff --git a/src/index/fsindexer.cpp b/src/index/fsindexer.cpp index 9e543b9f..ab2d25f8 100644 --- a/src/index/fsindexer.cpp +++ b/src/index/fsindexer.cpp @@ -214,6 +214,8 @@ bool FsIndexer::indexFiles(list& files) LOGDEB2(("FsIndexer::indexFiles: [%s]\n", it->c_str())); m_config->setKeyDir(path_getfather(*it)); + if (m_havelocalfields) + localfieldsfromconf(); walker.setSkippedNames(m_config->getSkippedNames()); // Check path against indexed areas and skipped names/paths @@ -285,22 +287,18 @@ void FsIndexer::localfieldsfromconf() string sfields; if (!m_config->getConfParam("localfields", sfields)) return; - list lfields; - if (!stringToStrings(sfields, lfields)) { - LOGERR(("FsIndexer::localfieldsfromconf: bad syntax for [%s]\n", - sfields.c_str())); - return; - } - for (list::const_iterator it = lfields.begin(); - it != lfields.end(); it++) { - ConfSimple conf(*it, 1, true); - list nmlst = conf.getNames(""); - for (list::const_iterator it1 = nmlst.begin(); - it1 != nmlst.end(); it1++) { - conf.get(*it1, m_localfields[*it1]); - LOGDEB2(("FsIndexer::localfieldsfromconf: [%s] => [%s]\n", - (*it1).c_str(), m_localfields[*it1].c_str())); - } + // Substitute ':' with '\n' inside the string. There is no way to escape ':' + for (string::size_type i = 0; i < sfields.size(); i++) + if (sfields[i] == ':') + sfields[i] = '\n'; + // Parse the result with a confsimple and add the results to the metadata + ConfSimple conf(sfields, 1, true); + list nmlst = conf.getNames(""); + for (list::const_iterator it = nmlst.begin(); + it != nmlst.end(); it++) { + conf.get(*it, m_localfields[*it]); + LOGDEB(("FsIndexer::localfieldsfromconf: [%s] => [%s]\n", + (*it).c_str(), m_localfields[*it].c_str())); } }