allow multiple field output from metadatacmds entry beginning with rclmulti. Add noxattrfields config variable to allow disabling extended attributes usage
This commit is contained in:
parent
0668c59201
commit
3fbcbc8c2b
@ -299,7 +299,8 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
|
|||||||
// Get fields computed from extended attributes. We use the
|
// Get fields computed from extended attributes. We use the
|
||||||
// original file, not the m_fn which may be the uncompressed temp
|
// original file, not the m_fn which may be the uncompressed temp
|
||||||
// file
|
// file
|
||||||
reapXAttrs(f);
|
if (!m_noxattrs)
|
||||||
|
reapXAttrs(f);
|
||||||
#endif //RCL_USE_XATTR
|
#endif //RCL_USE_XATTR
|
||||||
reapCmdMetadata(f);
|
reapCmdMetadata(f);
|
||||||
|
|
||||||
@ -379,6 +380,7 @@ void FileInterner::initcommon(RclConfig *cnf, int flags)
|
|||||||
for (unsigned int i = 0; i < MAXHANDLERS; i++)
|
for (unsigned int i = 0; i < MAXHANDLERS; i++)
|
||||||
m_tmpflgs[i] = false;
|
m_tmpflgs[i] = false;
|
||||||
m_targetMType = cstr_textplain;
|
m_targetMType = cstr_textplain;
|
||||||
|
m_cfg->getConfParam("noxattrfields", &m_noxattrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileInterner::FileInterner(const Rcl::Doc& idoc, RclConfig *cnf, int flags)
|
FileInterner::FileInterner(const Rcl::Doc& idoc, RclConfig *cnf, int flags)
|
||||||
@ -617,6 +619,19 @@ bool FileInterner::dijontorcl(Rcl::Doc& doc)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void docfieldfrommeta(RclConfig* cfg, const string& name,
|
||||||
|
const string &value, Rcl::Doc doc)
|
||||||
|
{
|
||||||
|
string fieldname = cfg->fieldCanon(name);
|
||||||
|
LOGDEB0(("Internfile:: setting [%s] from cmd value [%s]\n",
|
||||||
|
fieldname.c_str(), value.c_str()));
|
||||||
|
if (fieldname == cstr_dj_keymd) {
|
||||||
|
doc.dmtime = value;
|
||||||
|
} else {
|
||||||
|
doc.meta[fieldname] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Collect the ipath from the current path in the document tree.
|
// Collect the ipath from the current path in the document tree.
|
||||||
// While we're at it, we also set the mimetype and filename,
|
// While we're at it, we also set the mimetype and filename,
|
||||||
// which are special properties: we want to get them from the topmost
|
// which are special properties: we want to get them from the topmost
|
||||||
@ -638,28 +653,42 @@ void FileInterner::collectIpathAndMT(Rcl::Doc& doc) const
|
|||||||
bool hasipath = false;
|
bool hasipath = false;
|
||||||
|
|
||||||
#ifdef RCL_USE_XATTR
|
#ifdef RCL_USE_XATTR
|
||||||
// Set fields from extended file attributes.
|
if (!m_noxattrs) {
|
||||||
// These can be later augmented by values from inside the file
|
// Set fields from extended file attributes.
|
||||||
for (map<string,string>::const_iterator it = m_XAttrsFields.begin();
|
// These can be later augmented by values from inside the file
|
||||||
it != m_XAttrsFields.end(); it++) {
|
for (map<string,string>::const_iterator it = m_XAttrsFields.begin();
|
||||||
LOGDEB1(("Internfile:: setting [%s] from xattrs value [%s]\n",
|
it != m_XAttrsFields.end(); it++) {
|
||||||
m_cfg->fieldCanon(it->first).c_str(), it->second.c_str()));
|
LOGDEB1(("Internfile:: setting [%s] from xattrs value [%s]\n",
|
||||||
doc.meta[m_cfg->fieldCanon(it->first)] = it->second;
|
m_cfg->fieldCanon(it->first).c_str(), it->second.c_str()));
|
||||||
|
doc.meta[m_cfg->fieldCanon(it->first)] = it->second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif //RCL_USE_XATTR
|
#endif //RCL_USE_XATTR
|
||||||
|
|
||||||
// Set fields from external commands
|
// Set fields from external commands
|
||||||
// These override those from xattrs and can be later augmented by
|
// These override those from xattrs and can be later augmented by
|
||||||
// values from inside the file
|
// values from inside the file.
|
||||||
|
//
|
||||||
|
// This is a bit atrocious because some entry names are special:
|
||||||
|
// "modificationdate" will set mtime instead of an ordinary field,
|
||||||
|
// and the output from anything beginning with "rclmulti" will be
|
||||||
|
// interpreted as multiple fields in configuration file format...
|
||||||
for (map<string,string>::const_iterator it = m_cmdFields.begin();
|
for (map<string,string>::const_iterator it = m_cmdFields.begin();
|
||||||
it != m_cmdFields.end(); it++) {
|
it != m_cmdFields.end(); it++) {
|
||||||
string fieldname = m_cfg->fieldCanon(it->first);
|
if (!it->first.compare(0, 8, "rclmulti")) {
|
||||||
LOGDEB0(("Internfile:: setting [%s] from cmd value [%s]\n",
|
ConfSimple simple(it->second);
|
||||||
fieldname.c_str(), it->second.c_str()));
|
if (simple.ok()) {
|
||||||
if (fieldname == cstr_dj_keymd) {
|
vector<string> names = simple.getNames("");
|
||||||
doc.dmtime = it->second;
|
for (vector<string>::const_iterator nm = names.begin();
|
||||||
|
nm != names.end(); nm++) {
|
||||||
|
string value;
|
||||||
|
if (simple.get(*nm, value)) {
|
||||||
|
docfieldfrommeta(m_cfg, *nm, value, doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
doc.meta[fieldname] = it->second;
|
docfieldfrommeta(m_cfg, it->first, it->second, doc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -274,6 +274,8 @@ class FileInterner {
|
|||||||
|
|
||||||
Uncomp m_uncomp;
|
Uncomp m_uncomp;
|
||||||
|
|
||||||
|
bool m_noxattrs; // disable xattrs usage
|
||||||
|
|
||||||
// Pseudo-constructors
|
// Pseudo-constructors
|
||||||
void init(const string &fn, const struct stat *stp,
|
void init(const string &fn, const struct stat *stp,
|
||||||
RclConfig *cnf, int flags, const string *mtype = 0);
|
RclConfig *cnf, int flags, const string *mtype = 0);
|
||||||
|
|||||||
@ -288,6 +288,9 @@ webcachemaxmbs = 40
|
|||||||
# meaning-altering missing words.
|
# meaning-altering missing words.
|
||||||
snippetMaxPosWalk = 1000000
|
snippetMaxPosWalk = 1000000
|
||||||
|
|
||||||
|
# Disable extended attributes conversion to metadata fields
|
||||||
|
noxattrfields = 0
|
||||||
|
|
||||||
# You could specify different parameters for a subdirectory like this:
|
# You could specify different parameters for a subdirectory like this:
|
||||||
#[~/hungariandocs/plain]
|
#[~/hungariandocs/plain]
|
||||||
#defaultcharset = iso-8859-2
|
#defaultcharset = iso-8859-2
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user