Use proper path for DeepSearch xapian DB

This commit is contained in:
Gioacchino Mazzurco 2018-06-12 14:12:08 +02:00
parent 5a41b3cb37
commit 32014eaac1
No known key found for this signature in database
GPG key ID: A1FBCA3872E87051

View file

@ -21,11 +21,10 @@
#include <xapian.h> #include <xapian.h>
#include "retroshare/rsgxschannels.h" #include "retroshare/rsgxschannels.h"
#include "retroshare/rsinit.h"
struct DeepSearch struct DeepSearch
{ {
//DeepSearch(const std::string& dbPath) : mDbPath(dbPath) {}
struct SearchResult struct SearchResult
{ {
// TODO: Use RsUrl from extra_locators branch instead of plain string // TODO: Use RsUrl from extra_locators branch instead of plain string
@ -43,7 +42,7 @@ struct DeepSearch
results.clear(); results.clear();
// Open the database we're going to search. // Open the database we're going to search.
Xapian::Database db(mDbPath); Xapian::Database db(dbPath());
// Set up a QueryParser with a stemmer and suitable prefixes. // Set up a QueryParser with a stemmer and suitable prefixes.
Xapian::QueryParser queryparser; Xapian::QueryParser queryparser;
@ -79,7 +78,7 @@ struct DeepSearch
static void indexChannelGroup(const RsGxsChannelGroup& chan) static void indexChannelGroup(const RsGxsChannelGroup& chan)
{ {
Xapian::WritableDatabase db(mDbPath, Xapian::DB_CREATE_OR_OPEN); Xapian::WritableDatabase db(dbPath(), Xapian::DB_CREATE_OR_OPEN);
// Set up a TermGenerator that we'll use in indexing. // Set up a TermGenerator that we'll use in indexing.
Xapian::TermGenerator termgenerator; Xapian::TermGenerator termgenerator;
@ -121,13 +120,13 @@ struct DeepSearch
std::string idTerm("Qretroshare://channel?id="); std::string idTerm("Qretroshare://channel?id=");
idTerm += grpId.toStdString(); idTerm += grpId.toStdString();
Xapian::WritableDatabase db(mDbPath, Xapian::DB_CREATE_OR_OPEN); Xapian::WritableDatabase db(dbPath(), Xapian::DB_CREATE_OR_OPEN);
db.delete_document(idTerm); db.delete_document(idTerm);
} }
static void indexChannelPost(const RsGxsChannelPost& post) static void indexChannelPost(const RsGxsChannelPost& post)
{ {
Xapian::WritableDatabase db(mDbPath, Xapian::DB_CREATE_OR_OPEN); Xapian::WritableDatabase db(dbPath(), Xapian::DB_CREATE_OR_OPEN);
// Set up a TermGenerator that we'll use in indexing. // Set up a TermGenerator that we'll use in indexing.
Xapian::TermGenerator termgenerator; Xapian::TermGenerator termgenerator;
@ -168,7 +167,11 @@ private:
BAD_VALUENO = Xapian::BAD_VALUENO BAD_VALUENO = Xapian::BAD_VALUENO
}; };
static std::string mDbPath; static const std::string& dbPath()
{
static const std::string dbDir =
RsAccounts::AccountDirectory() + "/deep_search_xapian_db";
return dbDir;
}
}; };
std::string DeepSearch::mDbPath = "/tmp/deep_search_xapian_db";