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:
parent
46ccac27a4
commit
818b79b135
@ -121,7 +121,7 @@
|
||||
#define PACKAGE_NAME "Recoll"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "Recoll 1.28.5"
|
||||
#define PACKAGE_STRING "Recoll 1.29.0pre1"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "recoll"
|
||||
@ -130,7 +130,7 @@
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "1.28.5"
|
||||
#define PACKAGE_VERSION "1.29.0pre1"
|
||||
|
||||
/* putenv parameter is const */
|
||||
/* #undef PUTENV_ARG_CONST */
|
||||
|
||||
@ -574,19 +574,6 @@ static vector<string> argstovector(int argc, wchar_t **argv)
|
||||
return args;
|
||||
}
|
||||
|
||||
static vector<string> fileToArgs(const string& fn)
|
||||
{
|
||||
string reason, data;
|
||||
if (!file_to_string(fn, data, &reason)) {
|
||||
std::cerr << "Failed reading args file " << fn << " reason " <<
|
||||
reason << "\n";
|
||||
exit(1);
|
||||
}
|
||||
vector<string> args;
|
||||
stringToStrings(data, args);
|
||||
return args;
|
||||
}
|
||||
|
||||
|
||||
// Working directory before we change: it's simpler to change early
|
||||
// but some options need the original for computing absolute paths.
|
||||
@ -615,13 +602,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
vector<string> args = argstovector(argc, argv);
|
||||
|
||||
// Passing args through a temp file: this is used on Windows to
|
||||
// avoid issues with charsets in args (thought to avoid using
|
||||
// wmain, which proved false, but the args file was kept)
|
||||
if (args.size() == 1 && args[0][0] != '-') {
|
||||
args = fileToArgs(args[0]);
|
||||
}
|
||||
|
||||
vector<string> selpatterns;
|
||||
int sleepsecs{60};
|
||||
string a_config;
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||
|
||||
#define MyAppName "Recoll"
|
||||
#define MyAppVersion "1.27.6-20200913-7bbca8c7"
|
||||
#define MyAppVersion "1.29.0pre1-20200225-xxxxxxxx"
|
||||
#define MyAppPublisher "Recoll.org"
|
||||
#define MyAppURL "http://www.recoll.org"
|
||||
#define MyAppExeName "recoll.exe"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user