Finalize passing args from recoll to recollindex using a temp file

This commit is contained in:
Jean-Francois Dockes 2020-04-15 11:11:35 +01:00
parent c1ee5f0af5
commit 7c39eff719

View File

@ -223,7 +223,7 @@ void RclMain::periodic100()
} }
// On win32 we have trouble passing filename args on the command line // On win32 we have trouble passing filename args on the command line
// (recollindex would need to use wmain and process wchar args. So we // (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 // 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. // option, it's a file with the command line inside it.
bool RclMain::maybeArgsToFile(vector<string>& args) bool RclMain::maybeArgsToFile(vector<string>& args)
@ -233,20 +233,23 @@ bool RclMain::maybeArgsToFile(vector<string>& args)
TempFile temp(""); TempFile temp("");
m_idxargstmp = rememberTempFile(temp); m_idxargstmp = rememberTempFile(temp);
} }
bool hasrclindex = (args[0] == "recollindex");
if (hasrclindex) {
args.erase(args.begin());
}
string s; string s;
stringsToString(args, s); stringsToString(args, s);
fstream fout(m_idxargstmp->filename(), ios::out|ios::trunc); fstream fout(m_idxargstmp->filename(), ios::out|ios::trunc);
fout << s; fout << s;
fout.close(); fout.close();
return true; if (hasrclindex) {
if (args[0] == "recollindex") { args = {"recollindex", m_idxargstmp->filename()};
args = {args[0], m_idxargstmp->filename()};
} else { } else {
args = {m_idxargstmp->filename()}; args = {m_idxargstmp->filename()};
} }
return true; return true;
#else #else
args = args; (void)args;
return true; return true;
#endif #endif
} }
@ -263,7 +266,7 @@ bool RclMain::checkIdxPaths()
tr("Empty or non-existant paths in configuration file. " tr("Empty or non-existant paths in configuration file. "
"Click Ok to start indexing anyway " "Click Ok to start indexing anyway "
"(absent data will not be purged from the index):\n") + "(absent data will not be purged from the index):\n") +
QString::fromLocal8Bit(badpaths.c_str()), path2qs(badpaths),
QMessageBox::Ok, QMessageBox::Cancel, QMessageBox::NoButton); QMessageBox::Ok, QMessageBox::Cancel, QMessageBox::NoButton);
if (rep == QMessageBox::Cancel) if (rep == QMessageBox::Cancel)
return false; return false;