|
a/src/rcldb/rcldb.cpp |
|
b/src/rcldb/rcldb.cpp |
|
... |
|
... |
231 |
LOGDEB2(("Db::dbDataToRclDoc: data:\n%s\n", data.c_str()));
|
231 |
LOGDEB2(("Db::dbDataToRclDoc: data:\n%s\n", data.c_str()));
|
232 |
ConfSimple parms(data);
|
232 |
ConfSimple parms(data);
|
233 |
if (!parms.ok())
|
233 |
if (!parms.ok())
|
234 |
return false;
|
234 |
return false;
|
235 |
|
235 |
|
|
|
236 |
// Compute what index this comes from, and check for path translations
|
|
|
237 |
string dbdir = m_rcldb->m_basedir;
|
|
|
238 |
if (!m_rcldb->m_extraDbs.empty()) {
|
|
|
239 |
// As per trac.xapian.org/wiki/FAQ/MultiDatabaseDocumentID
|
|
|
240 |
unsigned int idxi = (docid-1) % (m_rcldb->m_extraDbs.size()+1);
|
|
|
241 |
// idxi is in [0, extraDbs.size()]. 0 is the base index, 1-n index
|
|
|
242 |
// into the additional dbs array
|
|
|
243 |
if (idxi) {
|
|
|
244 |
dbdir = m_rcldb->m_extraDbs[idxi - 1];
|
|
|
245 |
}
|
|
|
246 |
}
|
|
|
247 |
parms.get(Doc::keyurl, doc.url);
|
|
|
248 |
m_rcldb->m_config->urlrewrite(dbdir, doc.url);
|
|
|
249 |
|
236 |
// Special cases:
|
250 |
// Special cases:
|
237 |
parms.get(Doc::keyurl, doc.url);
|
|
|
238 |
parms.get(Doc::keytp, doc.mimetype);
|
251 |
parms.get(Doc::keytp, doc.mimetype);
|
239 |
parms.get(Doc::keyfmt, doc.fmtime);
|
252 |
parms.get(Doc::keyfmt, doc.fmtime);
|
240 |
parms.get(Doc::keydmt, doc.dmtime);
|
253 |
parms.get(Doc::keydmt, doc.dmtime);
|
241 |
parms.get(Doc::keyoc, doc.origcharset);
|
254 |
parms.get(Doc::keyoc, doc.origcharset);
|
242 |
parms.get(cstr_caption, doc.meta[Doc::keytt]);
|
255 |
parms.get(cstr_caption, doc.meta[Doc::keytt]);
|
|
... |
|
... |
262 |
for (vector<string>::const_iterator it = keys.begin();
|
275 |
for (vector<string>::const_iterator it = keys.begin();
|
263 |
it != keys.end(); it++) {
|
276 |
it != keys.end(); it++) {
|
264 |
if (doc.meta.find(*it) == doc.meta.end())
|
277 |
if (doc.meta.find(*it) == doc.meta.end())
|
265 |
parms.get(*it, doc.meta[*it]);
|
278 |
parms.get(*it, doc.meta[*it]);
|
266 |
}
|
279 |
}
|
|
|
280 |
doc.meta[Doc::keyurl] = doc.url;
|
267 |
doc.meta[Doc::keymt] = doc.dmtime.empty() ? doc.fmtime : doc.dmtime;
|
281 |
doc.meta[Doc::keymt] = doc.dmtime.empty() ? doc.fmtime : doc.dmtime;
|
268 |
return true;
|
282 |
return true;
|
269 |
}
|
283 |
}
|
270 |
|
284 |
|
271 |
// Return the positions list for the page break term
|
285 |
// Return the positions list for the page break term
|
|
... |
|
... |
577 |
return -1;
|
591 |
return -1;
|
578 |
}
|
592 |
}
|
579 |
return res;
|
593 |
return res;
|
580 |
}
|
594 |
}
|
581 |
|
595 |
|
582 |
bool Db::addQueryDb(const string &dir)
|
596 |
bool Db::addQueryDb(const string &_dir)
|
583 |
{
|
597 |
{
|
|
|
598 |
string dir = _dir;
|
584 |
LOGDEB(("Db::addQueryDb: ndb %p iswritable %d db [%s]\n", m_ndb,
|
599 |
LOGDEB0(("Db::addQueryDb: ndb %p iswritable %d db [%s]\n", m_ndb,
|
585 |
(m_ndb)?m_ndb->m_iswritable:0, dir.c_str()));
|
600 |
(m_ndb)?m_ndb->m_iswritable:0, dir.c_str()));
|
586 |
if (!m_ndb)
|
601 |
if (!m_ndb)
|
587 |
return false;
|
602 |
return false;
|
588 |
if (m_ndb->m_iswritable)
|
603 |
if (m_ndb->m_iswritable)
|
589 |
return false;
|
604 |
return false;
|
|
|
605 |
dir = path_canon(dir);
|
590 |
if (find(m_extraDbs.begin(), m_extraDbs.end(), dir) == m_extraDbs.end()) {
|
606 |
if (find(m_extraDbs.begin(), m_extraDbs.end(), dir) == m_extraDbs.end()) {
|
591 |
m_extraDbs.push_back(dir);
|
607 |
m_extraDbs.push_back(dir);
|
592 |
}
|
608 |
}
|
593 |
return adjustdbs();
|
609 |
return adjustdbs();
|
594 |
}
|
610 |
}
|