|
a/src/internfile/internfile.cpp |
|
b/src/internfile/internfile.cpp |
|
... |
|
... |
79 |
|
79 |
|
80 |
#ifdef RCL_USE_XATTR
|
80 |
#ifdef RCL_USE_XATTR
|
81 |
void FileInterner::reapXAttrs(const string& path)
|
81 |
void FileInterner::reapXAttrs(const string& path)
|
82 |
{
|
82 |
{
|
83 |
LOGDEB2(("FileInterner::reapXAttrs: [%s]\n", path.c_str()));
|
83 |
LOGDEB2(("FileInterner::reapXAttrs: [%s]\n", path.c_str()));
|
|
|
84 |
|
|
|
85 |
// Retrieve xattrs names from files and mapping table from config
|
84 |
vector<string> xnames;
|
86 |
vector<string> xnames;
|
85 |
if (!pxattr::list(path, &xnames)) {
|
87 |
if (!pxattr::list(path, &xnames)) {
|
86 |
LOGERR(("FileInterner::reapXattrs: pxattr::list: errno %d\n", errno));
|
88 |
LOGERR(("FileInterner::reapXattrs: pxattr::list: errno %d\n", errno));
|
87 |
return;
|
89 |
return;
|
88 |
}
|
90 |
}
|
89 |
const map<string, string>& xtof = m_cfg->getXattrToField();
|
91 |
const map<string, string>& xtof = m_cfg->getXattrToField();
|
|
|
92 |
|
|
|
93 |
// Record the xattrs: names found in the config are either skipped
|
|
|
94 |
// or mapped depending if the translation is empty. Other names
|
|
|
95 |
// are recorded as-is
|
90 |
for (vector<string>::const_iterator it = xnames.begin();
|
96 |
for (vector<string>::const_iterator it = xnames.begin();
|
91 |
it != xnames.end(); it++) {
|
97 |
it != xnames.end(); it++) {
|
|
|
98 |
string key = *it;
|
92 |
map<string, string>::const_iterator mit;
|
99 |
map<string, string>::const_iterator mit = xtof.find(*it);
|
93 |
if ((mit = xtof.find(*it)) != xtof.end()) {
|
100 |
if (mit != xtof.end()) {
|
94 |
string value;
|
101 |
if (mit->second.empty()) {
|
95 |
if (!pxattr::get(path, *it, &value, pxattr::PXATTR_NOFOLLOW)) {
|
|
|
96 |
LOGERR(("FileInterner::reapXattrs: pxattr::get failed"
|
|
|
97 |
"for %s, errno %d\n", (*it).c_str(), errno));
|
|
|
98 |
continue;
|
102 |
continue;
|
|
|
103 |
} else {
|
|
|
104 |
key = mit->second;
|
99 |
}
|
105 |
}
|
|
|
106 |
}
|
|
|
107 |
string value;
|
|
|
108 |
if (!pxattr::get(path, *it, &value, pxattr::PXATTR_NOFOLLOW)) {
|
|
|
109 |
LOGERR(("FileInterner::reapXattrs: pxattr::get failed"
|
|
|
110 |
"for %s, errno %d\n", (*it).c_str(), errno));
|
|
|
111 |
continue;
|
|
|
112 |
}
|
100 |
// Encode should we ?
|
113 |
// Encode should we ?
|
101 |
m_XAttrsFields[mit->second] = value;
|
114 |
m_XAttrsFields[key] = value;
|
102 |
LOGDEB2(("FileInterner::reapXAttrs: got [%s] -> [%s]\n",
|
115 |
LOGDEB2(("FileInterner::reapXAttrs: [%s] -> [%s]\n",
|
103 |
mit->second.c_str(), value.c_str()));
|
116 |
key.c_str(), value.c_str()));
|
104 |
}
|
|
|
105 |
}
|
117 |
}
|
106 |
}
|
118 |
}
|
107 |
#endif // RCL_USE_XATTR
|
119 |
#endif // RCL_USE_XATTR
|
108 |
|
120 |
|
109 |
// This is used when the user wants to retrieve a search result doc's parent
|
121 |
// This is used when the user wants to retrieve a search result doc's parent
|