Check if opkg_command failed, and if this is the case, stop the

update-process without showing a wrong UPDATE-SUCCESS.
This commit is contained in:
Gerhard Hoffmann 2023-10-10 16:01:45 +02:00
parent bdcb073bf8
commit 0d353cfbcf

View File

@ -795,39 +795,47 @@ bool Worker::updateFiles(quint8 percent) {
if (f.exists()) {
if (f.open(QIODevice::ReadOnly)) {
QTextStream in(&f);
int cmdCount = 0;
QStringList opkgCommands;
bool executeOpkgCommandFailed = false;
while (!in.atEnd()) {
QString line = in.readLine();
static const QRegularExpression comment("^\\s*#.*$");
if (line.indexOf(comment, 0) == -1) {
// found opkg command
QString opkgCommand = line.trimmed();
++cmdCount;
executeOpkgCommand(opkgCommand);
QString cmd = "\n " + opkgCommand;
emit appendText(cmd);
opkgCommands << cmd;
if (!executeOpkgCommand(opkgCommand)) {
executeOpkgCommandFailed = true;
} else {
QString cmd = "\n " + opkgCommand;
emit appendText(cmd);
opkgCommands << cmd;
m_ismasClient.setProgressInPercent(++percent);
m_updateStatus = UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND,
QString("EXEC OPKG-COMMAND ") + opkgCommand);
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.execOpkgCommand(m_updateStatus.m_statusDescription, ""));
m_ismasClient.setProgressInPercent(++percent);
m_updateStatus = UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND,
QString("EXEC OPKG-COMMAND ") + opkgCommand);
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.execOpkgCommand(m_updateStatus.m_statusDescription, ""));
}
}
}
f.close();
if (cmdCount > 0) {
m_displayIndex = 1;
QString prepend = QString("(") + QString("%1").arg(m_displayIndex).rightJustified(3, ' ') + QString(")")
+ QString(" Update opkg pakets ... ");
opkgCommands.prepend(prepend);
emit replaceLast(opkgCommands, UPDATE_STEP_DONE);
if (!executeOpkgCommandFailed) {
if (opkgCommands.size() > 0) {
m_displayIndex = 1;
QString prepend = QString("(") + QString("%1").arg(m_displayIndex).rightJustified(3, ' ') + QString(")")
+ QString(" Update opkg pakets ... ");
opkgCommands.prepend(prepend);
emit replaceLast(opkgCommands, UPDATE_STEP_DONE);
}
} else {
m_displayIndex = 1;
emit replaceLast(QString("(") + QString("%1").arg(m_displayIndex).rightJustified(3, ' ') + QString(")")
+ QString(" Update opkg pakets ... "), UPDATE_STEP_FAIL);
stopProgressLoop();
setProgress(100);
return false;
}
}
}