From 1509e8619c74580a9691d6493b0ce86953aa4700 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 23 Aug 2023 16:26:55 +0200 Subject: [PATCH] Send message to ISMAS when rsyncing a traiff-file --- worker.cpp | 34 ++++++++++++++++++++++++++++++---- worker.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/worker.cpp b/worker.cpp index 05f3692..a3890de 100644 --- a/worker.cpp +++ b/worker.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include @@ -514,11 +515,11 @@ bool Worker::updateTriggerSet() { if (repeat > 1) { 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; emit showErrorMessage("check update trigger", msg); } else { - emit showErrorMessage("check update trigger", QString("[%1]").arg(repeat)); + emit showErrorMessage("check update trigger", ""); } if ((repeat % 10) == 0) { @@ -970,7 +971,7 @@ bool Worker::syncCustomerRepositoryAndFS() { } int progress = 10; setProgress(progress); - QString const params("-vv " + QString const params("-vvv " "--recursive " "--progress " "--checksum " @@ -993,8 +994,25 @@ bool Worker::syncCustomerRepositoryAndFS() { qInfo() << "EXECUTING CMD..." << cmd; if (c.execute(m_customerRepository, QStringList() << "-c" << cmd)) { 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) { - 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 { Utils::printCriticalErrorMsg(QString("CMD ") + cmd + " FAILED: " @@ -1345,6 +1363,10 @@ QDebug operator<< (QDebug debug, UpdateStatus status) { debug << QString("UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED: ") << status.m_statusDescription; break; + case UPDATE_STATUS::RSYNC_FILE_SUCCESS: + debug << QString("UPDATE_STATUS::RSYNC_FILE_SUCCESS: ") + << status.m_statusDescription; + break; case UPDATE_STATUS::EXEC_OPKG_COMMANDS: debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS: ") << status.m_statusDescription; @@ -1468,6 +1490,10 @@ QString& operator<< (QString& str, UpdateStatus status) { str = QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS: "); str += status.m_statusDescription; break; + case UPDATE_STATUS::RSYNC_FILE_SUCCESS: + str = QString("UPDATE_STATUS::RSYNC_FILE_SUCCESS: "); + str += status.m_statusDescription; + break; //default:; } return str; diff --git a/worker.h b/worker.h index 8f46a1c..ea67786 100644 --- a/worker.h +++ b/worker.h @@ -41,6 +41,7 @@ enum class UPDATE_STATUS : quint8 { EXEC_OPKG_COMMANDS, RSYNC_UPDATES_FAILURE, RSYNC_UPDATES_SUCCESS, + RSYNC_FILE_SUCCESS, JSON_PARSE_FAILURE, UPDATE_PROCESS_SUCCESS, UPDATE_PROCESS_FAILURE,