check the stripchars options when adding an external index
This commit is contained in:
parent
10eaf5e6cb
commit
1805c367ea
@ -41,7 +41,7 @@ RclConfig *theconfig;
|
|||||||
const char *PrefsPack::dfltResListFormat =
|
const char *PrefsPack::dfltResListFormat =
|
||||||
"<table><tr><td><a href='%U'><img src='%I' width='64'></a></td>"
|
"<table><tr><td><a href='%U'><img src='%I' width='64'></a></td>"
|
||||||
"<td>%L <i>%S</i> <b>%T</b><br>"
|
"<td>%L <i>%S</i> <b>%T</b><br>"
|
||||||
"<span style='white-space:nowrap'>%M %D</span> <i>%U</i> %i<br>"
|
"<span style='white-space:nowrap'><i>%M</i> %D</span> <i>%U</i> %i<br>"
|
||||||
"%A %K</td></tr></table>"
|
"%A %K</td></tr></table>"
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -290,10 +290,16 @@ void rwSettings(bool writing)
|
|||||||
prefs.allExtraDbs.end(), dbdir) !=
|
prefs.allExtraDbs.end(), dbdir) !=
|
||||||
prefs.allExtraDbs.end())
|
prefs.allExtraDbs.end())
|
||||||
continue;
|
continue;
|
||||||
if (!Rcl::Db::testDbDir(dbdir)) {
|
bool stripped;
|
||||||
|
if (!Rcl::Db::testDbDir(dbdir, &stripped)) {
|
||||||
LOGERR(("Not a xapian index: [%s]\n", dbdir.c_str()));
|
LOGERR(("Not a xapian index: [%s]\n", dbdir.c_str()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (stripped != o_index_stripchars) {
|
||||||
|
LOGERR(("Incompatible character stripping: [%s]\n",
|
||||||
|
dbdir.c_str()));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
prefs.allExtraDbs.push_back(dbdir);
|
prefs.allExtraDbs.push_back(dbdir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -305,8 +311,11 @@ void rwSettings(bool writing)
|
|||||||
// actually there: useful for removable volumes.
|
// actually there: useful for removable volumes.
|
||||||
for (list<string>::iterator it = prefs.activeExtraDbs.begin();
|
for (list<string>::iterator it = prefs.activeExtraDbs.begin();
|
||||||
it != prefs.activeExtraDbs.end();) {
|
it != prefs.activeExtraDbs.end();) {
|
||||||
if (!Rcl::Db::testDbDir(*it)) {
|
bool stripped;
|
||||||
LOGINFO(("Not a xapian index: [%s]\n", it->c_str()));
|
if (!Rcl::Db::testDbDir(*it, &stripped) ||
|
||||||
|
stripped != o_index_stripchars) {
|
||||||
|
LOGINFO(("Not a Xapian index or char stripping differs: [%s]\n",
|
||||||
|
it->c_str()));
|
||||||
it = prefs.activeExtraDbs.erase(it);
|
it = prefs.activeExtraDbs.erase(it);
|
||||||
} else {
|
} else {
|
||||||
it++;
|
it++;
|
||||||
@ -327,8 +336,11 @@ void rwSettings(bool writing)
|
|||||||
prefs.activeExtraDbs.end(), dbdir) !=
|
prefs.activeExtraDbs.end(), dbdir) !=
|
||||||
prefs.activeExtraDbs.end())
|
prefs.activeExtraDbs.end())
|
||||||
continue;
|
continue;
|
||||||
if (!Rcl::Db::testDbDir(dbdir)) {
|
bool strpd;
|
||||||
LOGERR(("Not a xapian index: [%s]\n", dbdir.c_str()));
|
if (!Rcl::Db::testDbDir(dbdir, &strpd) ||
|
||||||
|
strpd != o_index_stripchars) {
|
||||||
|
LOGERR(("Not a Xapian dir or diff. char stripping: [%s]\n",
|
||||||
|
dbdir.c_str()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
prefs.activeExtraDbs.push_back(dbdir);
|
prefs.activeExtraDbs.push_back(dbdir);
|
||||||
|
|||||||
@ -533,11 +533,18 @@ void UIPrefsDialog::addExtraDbPB_clicked()
|
|||||||
|
|
||||||
LOGDEB(("ExtraDbDial: got: [%s]\n", dbdir.c_str()));
|
LOGDEB(("ExtraDbDial: got: [%s]\n", dbdir.c_str()));
|
||||||
path_catslash(dbdir);
|
path_catslash(dbdir);
|
||||||
if (!Rcl::Db::testDbDir(dbdir)) {
|
bool stripped;
|
||||||
|
if (!Rcl::Db::testDbDir(dbdir, &stripped)) {
|
||||||
QMessageBox::warning(0, "Recoll",
|
QMessageBox::warning(0, "Recoll",
|
||||||
tr("The selected directory does not appear to be a Xapian index"));
|
tr("The selected directory does not appear to be a Xapian index"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (o_index_stripchars != stripped) {
|
||||||
|
QMessageBox::warning(0, "Recoll",
|
||||||
|
tr("Cant add index with different case/diacritics"
|
||||||
|
" stripping option"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (samedir(dbdir, theconfig->getDbDir())) {
|
if (samedir(dbdir, theconfig->getDbDir())) {
|
||||||
QMessageBox::warning(0, "Recoll",
|
QMessageBox::warning(0, "Recoll",
|
||||||
tr("This is the main/local index!"));
|
tr("This is the main/local index!"));
|
||||||
|
|||||||
@ -856,18 +856,29 @@ size_t Db::whatDbIdx(const Doc& doc)
|
|||||||
return doc.xdocid % (m_extraDbs.size()+1);
|
return doc.xdocid % (m_extraDbs.size()+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Db::testDbDir(const string &dir)
|
bool Db::testDbDir(const string &dir, bool *stripped_p)
|
||||||
{
|
{
|
||||||
string aerr;
|
string aerr;
|
||||||
|
bool mstripped = true;
|
||||||
LOGDEB(("Db::testDbDir: [%s]\n", dir.c_str()));
|
LOGDEB(("Db::testDbDir: [%s]\n", dir.c_str()));
|
||||||
try {
|
try {
|
||||||
Xapian::Database db(dir);
|
Xapian::Database db(dir);
|
||||||
|
// If we have terms with a leading ':' it's an
|
||||||
|
// unstripped index
|
||||||
|
Xapian::TermIterator term = db.allterms_begin(":");
|
||||||
|
if (term == db.allterms_end())
|
||||||
|
mstripped = true;
|
||||||
|
else
|
||||||
|
mstripped = false;
|
||||||
} XCATCHERROR(aerr);
|
} XCATCHERROR(aerr);
|
||||||
if (!aerr.empty()) {
|
if (!aerr.empty()) {
|
||||||
LOGERR(("Db::Open: error while trying to open database "
|
LOGERR(("Db::Open: error while trying to open database "
|
||||||
"from [%s]: %s\n", dir.c_str(), aerr.c_str()));
|
"from [%s]: %s\n", dir.c_str(), aerr.c_str()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (stripped_p)
|
||||||
|
*stripped_p = mstripped;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -301,8 +301,9 @@ class Db {
|
|||||||
* other: order of database in add_database() sequence.
|
* other: order of database in add_database() sequence.
|
||||||
*/
|
*/
|
||||||
size_t whatDbIdx(const Doc& doc);
|
size_t whatDbIdx(const Doc& doc);
|
||||||
|
|
||||||
/** Tell if directory seems to hold xapian db */
|
/** Tell if directory seems to hold xapian db */
|
||||||
static bool testDbDir(const string &dir);
|
static bool testDbDir(const string &dir, bool *stripped = 0);
|
||||||
|
|
||||||
/** Return the index terms that match the input string
|
/** Return the index terms that match the input string
|
||||||
* Expansion is performed either with either wildcard or regexp processing
|
* Expansion is performed either with either wildcard or regexp processing
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user