Use exit() instead of quit() to be able to add a returnCode in case of failure.

This commit is contained in:
2023-08-03 09:06:50 +02:00
parent 0ee92f0181
commit 9b08420ac1
3 changed files with 51 additions and 14 deletions

View File

@@ -65,7 +65,8 @@ Worker::Worker(hwinf *hw,
, m_ismasUpdateRequests(ISMAS_UPDATE_REQUESTS)
, m_waitForNewUpdates(this)
, m_filesToUpdate()
, m_updateProcessRunning(false) {
, m_updateProcessRunning(false)
, m_returnCode(0) {
QDir::setCurrent(m_workingDirectory);
@@ -127,6 +128,7 @@ void Worker::privateUpdate() {
bool sentIsmasLastVersionNotification = false;
m_returnCode = -1;
QDir customerRepository(m_customerRepository);
if (!customerRepository.exists()) {
if (m_gc.gitCloneAndCheckoutBranch()) {
@@ -146,10 +148,7 @@ void Worker::privateUpdate() {
m_ismasClient.setProgressInPercent(95);
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") + m_ismasClient.updateOfPSAActivated());
//emit setProgress(100);
//m_ismasClient.setProgressInPercent(100);
//emit appendText(QString(""), UPDATE_STEP_SUCCESS);
m_returnCode = 0;
}
} else {
// checkout branch
@@ -199,22 +198,51 @@ void Worker::privateUpdate() {
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAActivated());
m_returnCode = 0;
} else {
m_returnCode = -9;
}
} else {
m_returnCode = -8;
}
} else {
m_returnCode = -7;
}
} else {
m_returnCode = -6;
}
} else {
m_returnCode = -5;
}
} else {
m_returnCode = -4;
}
} else {
m_returnCode = -3;
}
} else {
m_returnCode = -2;
}
} else {
m_returnCode = -1;
}
}
if (!sentIsmasLastVersionNotification) {
// try even if the backend is not connected
sendIsmasLastVersionNotification();
emit setProgress(100);
m_ismasClient.setProgressInPercent(100);
emit appendText(QString(""), UPDATE_STEP_SUCCESS);
if (m_returnCode == 0) {
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSASucceeded(""));
emit appendText(QString(""), UPDATE_STEP_SUCCESS);
} else {
emit appendText(QString(""), UPDATE_STEP_FAIL);
}
sendIsmasLastVersionNotification();
}
m_updateProcessRunning = false;
@@ -253,7 +281,7 @@ bool Worker::backendConnected() {
bool ismas = obj.value("ISMAS").toBool();
QString status = obj.value("Broker").toString();
qCritical() << "XXXXXXXXXX STATUS" << status;
qCritical() << "STATUS" << status;
if (ismas) {
if (status == "Connected") {
@@ -494,7 +522,9 @@ bool Worker::updateFiles(quint8 percent) {
}
}
qCritical() << "XXXXXXXXXXXXXXXXXXX FILES_TO_WORK_ON" << filesToDownload;
if (filesToDownload.size() > 0) {
qCritical() << "FILES_TO_WORK_ON" << filesToDownload;
}
return m_update->doUpdate(m_displayIndex, filesToDownload);
}