Skip to content

Commit c093f56

Browse files
author
kbay
committed
mwc713/mwc-node executable doesn't exist. Better handling
1 parent e5ea012 commit c093f56

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

node/MwcNode.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,17 @@ QProcess * MwcNode::initNodeProcess(const QString & dataPath, const QString & ne
153153
params.push_back("--floonet");
154154

155155
nodeStartTime = QDateTime::currentMSecsSinceEpoch();
156-
commandLine = "'" + QFileInfo(nodePath).canonicalFilePath() + "'";
156+
157+
QString nodeExecutablePath = QFileInfo(nodePath).canonicalFilePath();
158+
if (nodeExecutablePath.isEmpty()) {
159+
// file not found. Let's report it clear way
160+
logger::logInfo("MWC-NODE", "error. mwc-node canonical path is empty");
161+
162+
reportNodeFatalError( "mwc-node executable is not found. Expected location at:\n\n" + nodeExecutablePath );
163+
return nullptr;
164+
}
165+
166+
commandLine = "'" + nodeExecutablePath + "'";
157167
for (auto & p : params) {
158168
commandLine += " '" + p + "'";
159169
}

util/Process.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ namespace util {
2222

2323

2424
bool processWaitForFinished( QProcess * process, int timeoutMs, const QString & processName ) {
25+
if (process==nullptr)
26+
return true;
27+
2528
if (process->state() != QProcess::Running)
2629
return true;
2730

wallet/mwc713.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ bool MWC713::checkWalletInitialized() {
7272
Q_ASSERT(mwc713process==nullptr);
7373
mwc713process = initMwc713process( {}, {"state"}, false );
7474

75+
if (mwc713process==nullptr)
76+
return false;
77+
7578
if (!util::processWaitForFinished( mwc713process, 3000, "mwc713")) {
7679
mwc713process->terminate();
7780
util::processWaitForFinished( mwc713process, 3000, "mwc713");
@@ -113,7 +116,18 @@ QProcess * MWC713::initMwc713process( const QStringList & envVariables, const Q
113116
params.append( paramsPlus );
114117

115118
walletStartTime = QDateTime::currentMSecsSinceEpoch();
116-
commandLine = "'" + QFileInfo(mwc713Path).canonicalFilePath() + "'";
119+
120+
QString filePath = QFileInfo(mwc713Path).canonicalFilePath();
121+
if (filePath.isEmpty()) {
122+
// file not found. Let's report it clear way
123+
logger::logInfo("MWC713", "error. mwc713 canonical path is empty");
124+
125+
appendNotificationMessage( notify::MESSAGE_LEVEL::FATAL_ERROR, "mwc713 executable is not found. Expected location at:\n\n" + mwc713Path );
126+
return nullptr;
127+
128+
}
129+
130+
commandLine = "'" + filePath + "'";
117131
for (auto & p : params) {
118132
if (p=="-r" || p==mwc::PROMPTS_MWC713 )
119133
continue; // skipping prompt parameter. It is not needed for troubleshouting
@@ -171,6 +185,8 @@ void MWC713::start(bool loginWithLastKnownPassword) {
171185

172186
// Creating process and starting
173187
mwc713process = initMwc713process({}, {} );
188+
if (mwc713process==nullptr)
189+
return;
174190

175191
inputParser = new tries::Mwc713InputParser();
176192

@@ -206,6 +222,8 @@ void MWC713::start2init(QString password) {
206222
// Creating process and starting
207223

208224
mwc713process = initMwc713process({"MWC_PASSWORD", password}, {"init"} );
225+
if (mwc713process==nullptr)
226+
return;
209227

210228
inputParser = new tries::Mwc713InputParser();
211229

@@ -246,6 +264,8 @@ void MWC713::start2recover(const QVector<QString> & seed, QString password) {
246264
// Creating process and starting
247265
// Mnemonic will moved into variables
248266
mwc713process = initMwc713process({"MWC_PASSWORD", password, "MWC_MNEMONIC", seedStr}, {"recover", "--mnemonic", "env" } );
267+
if (mwc713process==nullptr)
268+
return;
249269

250270
inputParser = new tries::Mwc713InputParser();
251271

0 commit comments

Comments
 (0)