Send message to ISMAS when rsyncing a traiff-file

This commit is contained in:
Gerhard Hoffmann 2023-08-23 16:26:55 +02:00
parent a8df026a80
commit 1509e8619c
2 changed files with 31 additions and 4 deletions

View File

@ -15,6 +15,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <QPushButton> #include <QPushButton>
#include <QJsonParseError> #include <QJsonParseError>
#include <Qt>
#include <thread> #include <thread>
@ -514,11 +515,11 @@ bool Worker::updateTriggerSet() {
if (repeat > 1) { if (repeat > 1) {
int const durationMs = QTime::currentTime().msecsSinceStartOfDay() - startMs; int const durationMs = QTime::currentTime().msecsSinceStartOfDay() - startMs;
QString const &msg = QString("[%1] time: %2.%3s").arg(repeat).arg(durationMs / 1000).arg(durationMs % 1000); QString const &msg = QString("elapsed: %1.%2s").arg(durationMs / 1000).arg(durationMs % 1000);
qInfo() << "REPEAT" << msg; qInfo() << "REPEAT" << msg;
emit showErrorMessage("check update trigger", msg); emit showErrorMessage("check update trigger", msg);
} else { } else {
emit showErrorMessage("check update trigger", QString("[%1]").arg(repeat)); emit showErrorMessage("check update trigger", "");
} }
if ((repeat % 10) == 0) { if ((repeat % 10) == 0) {
@ -970,7 +971,7 @@ bool Worker::syncCustomerRepositoryAndFS() {
} }
int progress = 10; int progress = 10;
setProgress(progress); setProgress(progress);
QString const params("-vv " QString const params("-vvv "
"--recursive " "--recursive "
"--progress " "--progress "
"--checksum " "--checksum "
@ -993,8 +994,25 @@ bool Worker::syncCustomerRepositoryAndFS() {
qInfo() << "EXECUTING CMD..." << cmd; qInfo() << "EXECUTING CMD..." << cmd;
if (c.execute(m_customerRepository, QStringList() << "-c" << cmd)) { if (c.execute(m_customerRepository, QStringList() << "-c" << cmd)) {
QStringList result = c.getCommandResult().split('\n'); QStringList result = c.getCommandResult().split('\n');
QString const &p1 = "send_files mapped ";
QString const &p2 = "of size";
for (int i = 0; i < result.size(); ++i) { for (int i = 0; i < result.size(); ++i) {
qInfo() << result.at(i); QString line = result.at(i);
qInfo() << line;
// "send_files mapped etc/psa_tariff/tariff01.json of size 19339"
int sendFilesAtPos = line.indexOf(p1);
int ofSizeAtPos = line.indexOf(p2);
if (sendFilesAtPos != -1 && ofSizeAtPos != -1) {
sendFilesAtPos += p1.length();
QString const &s = line.mid(sendFilesAtPos, ofSizeAtPos - sendFilesAtPos).trimmed();
m_updateStatus = UpdateStatus(UPDATE_STATUS::RSYNC_FILE_SUCCESS,
QString("RSYNC FILE ") + s.split("/").last() +
" LAST-COMMIT: " + m_gc.gitLastCommit(s));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.rsyncFile(m_updateStatus.m_statusDescription, ""));
}
} }
} else { } else {
Utils::printCriticalErrorMsg(QString("CMD ") + cmd + " FAILED: " Utils::printCriticalErrorMsg(QString("CMD ") + cmd + " FAILED: "
@ -1345,6 +1363,10 @@ QDebug operator<< (QDebug debug, UpdateStatus status) {
debug << QString("UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED: ") debug << QString("UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED: ")
<< status.m_statusDescription; << status.m_statusDescription;
break; break;
case UPDATE_STATUS::RSYNC_FILE_SUCCESS:
debug << QString("UPDATE_STATUS::RSYNC_FILE_SUCCESS: ")
<< status.m_statusDescription;
break;
case UPDATE_STATUS::EXEC_OPKG_COMMANDS: case UPDATE_STATUS::EXEC_OPKG_COMMANDS:
debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS: ") debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS: ")
<< status.m_statusDescription; << status.m_statusDescription;
@ -1468,6 +1490,10 @@ QString& operator<< (QString& str, UpdateStatus status) {
str = QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS: "); str = QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS: ");
str += status.m_statusDescription; str += status.m_statusDescription;
break; break;
case UPDATE_STATUS::RSYNC_FILE_SUCCESS:
str = QString("UPDATE_STATUS::RSYNC_FILE_SUCCESS: ");
str += status.m_statusDescription;
break;
//default:; //default:;
} }
return str; return str;

View File

@ -41,6 +41,7 @@ enum class UPDATE_STATUS : quint8 {
EXEC_OPKG_COMMANDS, EXEC_OPKG_COMMANDS,
RSYNC_UPDATES_FAILURE, RSYNC_UPDATES_FAILURE,
RSYNC_UPDATES_SUCCESS, RSYNC_UPDATES_SUCCESS,
RSYNC_FILE_SUCCESS,
JSON_PARSE_FAILURE, JSON_PARSE_FAILURE,
UPDATE_PROCESS_SUCCESS, UPDATE_PROCESS_SUCCESS,
UPDATE_PROCESS_FAILURE, UPDATE_PROCESS_FAILURE,