Windows: simplified recollindex argument passing.

Because of the use of wmain(), we don't need the imperfect method of using
a temporary file. This should have been simplified when switching to wmain
but was not for lack of time.
This commit is contained in:
Jean-Francois Dockes
2021-02-25 15:30:17 +00:00
parent 46ccac27a4
commit 818b79b135
5 changed files with 3 additions and 79 deletions
-54
View File
@@ -214,52 +214,10 @@ void RclMain::periodic100()
}
}
// On win32 we have trouble passing filename args on the command line
// (recollindex would need to use wmain and process wchar args). So we
// use a temp file: if the first and only arg to recollindex is not an
// option, it's a file with the command line inside it.
bool RclMain::maybeArgsToFile(vector<string>& args)
{
#ifdef _WIN32
if (!m_idxargstmp || !m_idxargstmp->ok()) {
TempFile temp("");
m_idxargstmp = rememberTempFile(temp);
}
LOGDEB0("RclMain::maybeArgsToFile: temp file name [" <<
m_idxargstmp->filename() << "]\n");
bool hasrclindex = (args[0] == "recollindex");
if (hasrclindex) {
args.erase(args.begin());
}
string s;
stringsToString(args, s);
fstream fout;
if (!path_streamopen(m_idxargstmp->filename(), ios::out|ios::trunc, fout)) {
QMessageBox::warning(
0, "Recoll", tr("Could not start recollindex (temp file error)"));
return false;
}
fout << s;
fout.close();
if (hasrclindex) {
args = {"recollindex", m_idxargstmp->filename()};
} else {
args = {m_idxargstmp->filename()};
}
return true;
#else
(void)args;
return true;
#endif
}
bool RclMain::checkIdxPaths()
{
string badpaths;
vector<string> args{"recollindex", "-c", theconfig->getConfDir(), "-E"};
if (!maybeArgsToFile(args)) {
return false;
}
ExecCmd::backtick(args, badpaths);
if (!badpaths.empty()) {
int rep = QMessageBox::warning(
@@ -329,9 +287,6 @@ void RclMain::toggleIndexing()
args.push_back(m_idxreasontmp->filename());
}
m_idxproc = new ExecCmd;
if (!maybeArgsToFile(args)) {
return;
}
m_idxproc->startExec("recollindex", args, false, false);
}
break;
@@ -437,9 +392,6 @@ void RclMain::rebuildIndex()
args.push_back(m_idxreasontmp->filename());
}
m_idxproc = new ExecCmd;
if (!maybeArgsToFile(args)) {
return;
}
m_idxproc->startExec("recollindex", args, false, false);
}
}
@@ -566,9 +518,6 @@ void RclMain::specialIndex()
args.push_back(top);
}
m_idxproc = new ExecCmd;
if (!maybeArgsToFile(args)) {
return;
}
LOGINFO("specialIndex: exec: " << execToString("recollindex", args) <<endl);
m_idxproc->startExec("recollindex", args, false, false);
}
@@ -591,9 +540,6 @@ void RclMain::updateIdxForDocs(vector<Rcl::Doc>& docs)
}
args.insert(args.end(), paths.begin(), paths.end());
m_idxproc = new ExecCmd;
if (!maybeArgsToFile(args)) {
return;
}
m_idxproc->startExec("recollindex", args, false, false);
// Call periodic100 to update the menu entries states
periodic100();
-2
View File
@@ -227,7 +227,6 @@ private:
ExecCmd *m_idxproc{0}; // Indexing process
bool m_idxkilled{false}; // Killed my process
TempFile *m_idxreasontmp{nullptr};
TempFile *m_idxargstmp{nullptr};
map<QString, QAction*> m_stemLangToId;
vector<string> m_catgbutvec;
int m_catgbutvecidx{0};
@@ -283,7 +282,6 @@ private:
virtual bool containerUpToDate(Rcl::Doc& doc);
virtual void setFiltSpec();
virtual bool checkIdxPaths();
bool maybeArgsToFile(std::vector<std::string>& args);
};
#endif // RCLMAIN_W_H