From 4d911028d8101d6dc29b034fa9ec2e11bfc50092 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Wed, 3 Aug 2016 07:12:48 +0200 Subject: [PATCH] Fix topdirs existence checking for non default config dirs --- src/index/recollindex.cpp | 2 +- src/qtgui/rclm_idx.cpp | 57 ++++++++++++++++++++++++--------------- src/qtgui/rclmain_w.h | 1 + 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/src/index/recollindex.cpp b/src/index/recollindex.cpp index a29e02bc..e903196e 100644 --- a/src/index/recollindex.cpp +++ b/src/index/recollindex.cpp @@ -477,7 +477,7 @@ int main(int argc, char **argv) Usage(); if ((op_flags & OPT_Z) && (op_flags & (OPT_m))) Usage(); - if ((op_flags & OPT_E) && (op_flags & ~OPT_E)) { + if ((op_flags & OPT_E) && (op_flags & ~(OPT_E|OPT_c))) { Usage(); } string reason; diff --git a/src/qtgui/rclm_idx.cpp b/src/qtgui/rclm_idx.cpp index 63928201..e86f3767 100644 --- a/src/qtgui/rclm_idx.cpp +++ b/src/qtgui/rclm_idx.cpp @@ -177,6 +177,30 @@ void RclMain::periodic100() fileExit(); } +bool RclMain::checkIdxPaths() +{ + vector args; + + string badpaths; + args.push_back("recollindex"); + args.push_back("-E"); + args.push_back("-c"); + args.push_back(theconfig->getConfDir()); + ExecCmd::backtick(args, badpaths); + if (!badpaths.empty()) { + int rep = + QMessageBox::warning(0, tr("Bad paths"), + tr("Bad paths in configuration file:\n") + + QString::fromLocal8Bit(badpaths.c_str()), + QMessageBox::Ok, + QMessageBox::Cancel, + QMessageBox::NoButton); + if (rep == QMessageBox::Cancel) + return false; + } + return true; +} + // This gets called when the "update index" action is activated. It executes // the requested action, and disables the menu entry. This will be // re-enabled by the indexing status check @@ -228,25 +252,10 @@ void RclMain::toggleIndexing() string mhd; m_firstIndexing = !theconfig->getMissingHelperDesc(mhd); - vector args; - - string badpaths; - args.push_back("recollindex"); - args.push_back("-E"); - ExecCmd::backtick(args, badpaths); - if (!badpaths.empty()) { - int rep = - QMessageBox::warning(0, tr("Bad paths"), - tr("Bad paths in configuration file:\n") + - QString::fromLocal8Bit(badpaths.c_str()), - QMessageBox::Ok, - QMessageBox::Cancel, - QMessageBox::NoButton); - if (rep == QMessageBox::Cancel) - return; + if (!checkIdxPaths()) { + return; } - - args.clear(); + vector args; args.push_back("-c"); args.push_back(theconfig->getConfDir()); m_idxproc = new ExecCmd; @@ -280,9 +289,10 @@ void RclMain::rebuildIndex() QMessageBox::NoButton); if (rep == QMessageBox::Ok) { #ifdef _WIN32 - // Under windows, it's necessary to close the db here, else Xapian - // won't be able to do what it wants with the (open) files. Of course - // if there are several GUI instances, this won't work... + // Under windows, it's necessary to close the db here, + // else Xapian won't be able to do what it wants with the + // (open) files. Of course if there are several GUI + // instances, this won't work... if (rcldb) rcldb->close(); #endif // _WIN32 @@ -291,6 +301,11 @@ void RclMain::rebuildIndex() // firstIndexing is used for) string mhd; m_firstIndexing = !theconfig->getMissingHelperDesc(mhd); + + if (!checkIdxPaths()) { + return; + } + vector args; args.push_back("-c"); args.push_back(theconfig->getConfDir()); diff --git a/src/qtgui/rclmain_w.h b/src/qtgui/rclmain_w.h index 5de6dbb8..31fe1210 100644 --- a/src/qtgui/rclmain_w.h +++ b/src/qtgui/rclmain_w.h @@ -265,6 +265,7 @@ private: virtual void initiateQuery(); virtual bool containerUpToDate(Rcl::Doc& doc); virtual void setFiltSpec(); + virtual bool checkIdxPaths(); }; #endif // RCLMAIN_W_H