Make path searches case-insensitive on windows.

This commit is contained in:
Jean-Francois Dockes
2016-08-06 12:20:45 +02:00
parent 361d3aa256
commit e0a79455ae
7 changed files with 229 additions and 34 deletions
+12 -4
View File
@@ -56,6 +56,7 @@ using namespace std;
#include "expansiondbs.h"
#include "rclinit.h"
#include "internfile.h"
#include "utf8fn.h"
// Recoll index format version is stored in user metadata. When this change,
// we can't open the db and will have to reindex.
@@ -159,7 +160,9 @@ Db::Native::~Native()
#ifdef IDX_THREADS
if (m_havewriteq) {
void *status = m_wqueue.setTerminateAndWait();
LOGDEB2("Native::~Native: worker status " << (long(status)) << "\n" );
if (status) {
LOGDEB1("Native::~Native: worker status " << status << "\n");
}
}
#endif // IDX_THREADS
}
@@ -1060,7 +1063,6 @@ class TextSplitDb : public TextSplitP {
// Reimplement text_to_words to insert the begin and end anchor terms.
virtual bool text_to_words(const string &in)
{
bool ret = false;
string ermsg;
try {
@@ -1089,8 +1091,6 @@ class TextSplitDb : public TextSplitP {
goto out;
}
ret = true;
out:
basepos += curpos + 100;
return true;
@@ -1296,6 +1296,14 @@ bool Db::addOrUpdate(const string &udi, const string &parent_udi, Doc &doc)
// Split and index the path from the url for path-based filtering
{
string path = url_gpathS(doc.url);
#ifdef _WIN32
// Windows file names are case-insensitive, so we
// translate to UTF-8 and lowercase
string upath = compute_utf8fn(m_config, path, false);
unacmaybefold(upath, path, "UTF-8", UNACOP_FOLD);
#endif
vector<string> vpath;
stringToTokens(path, vpath, "/");
// If vpath is not /, the last elt is the file/dir name, not a
+16 -6
View File
@@ -937,11 +937,20 @@ bool SearchDataClauseFilename::toNativeQuery(Rcl::Db &db, void *p)
// Translate a dir: path filtering clause. See comments in .h
bool SearchDataClausePath::toNativeQuery(Rcl::Db &db, void *p)
{
LOGDEB("SearchDataClausePath::toNativeQuery: [" << (m_text) << "]\n" );
LOGDEB("SearchDataClausePath::toNativeQuery: [" << m_text << "]\n");
Xapian::Query *qp = (Xapian::Query *)p;
*qp = Xapian::Query();
if (m_text.empty()) {
string ltext;
#ifdef _WIN32
// Windows file names are case-insensitive, so we lowercase (same
// as when indexing)
unacmaybefold(m_text, ltext, "UTF-8", UNACOP_FOLD);
#else
ltext = m_text;
#endif
if (ltext.empty()) {
LOGERR("SearchDataClausePath: empty path??\n" );
m_reason = "Empty path ?";
return false;
@@ -949,13 +958,13 @@ bool SearchDataClausePath::toNativeQuery(Rcl::Db &db, void *p)
vector<Xapian::Query> orqueries;
if (path_isabsolute(m_text))
if (path_isabsolute(ltext))
orqueries.push_back(Xapian::Query(wrap_prefix(pathelt_prefix)));
else
m_text = path_tildexpand(m_text);
ltext = path_tildexpand(ltext);
vector<string> vpath;
stringToTokens(m_text, vpath, "/");
stringToTokens(ltext, vpath, "/");
for (vector<string>::const_iterator pit = vpath.begin();
pit != vpath.end(); pit++){
@@ -967,7 +976,8 @@ bool SearchDataClausePath::toNativeQuery(Rcl::Db &db, void *p)
*pit, exp, sterm, wrap_prefix(pathelt_prefix))) {
return false;
}
LOGDEB0("SDataPath::toNative: exp size " << (exp.size()) << ". Exp: " << (stringsToString(exp)) << "\n" );
LOGDEB0("SDataPath::toNative: exp size " << exp.size() << ". Exp: " <<
stringsToString(exp) << "\n");
if (exp.size() == 1)
orqueries.push_back(Xapian::Query(exp[0]));
else