From d4ddbbee21833a5d4f4051c0ca73789c446d81c3 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Mon, 30 Oct 2023 15:05:30 +0100 Subject: [PATCH] Add class UpdateProcessRunning: use for sending SEND-LAST-VERSION as part of its destruktor: RAII-pattern. --- worker.h | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/worker.h b/worker.h index 1b78fae..c05768b 100644 --- a/worker.h +++ b/worker.h @@ -193,17 +193,27 @@ class Worker : public QObject { int sendUpdateSucceededAndActivated(); int sendFinalResult(); + struct UpdateProcessRunning { + Worker *m_worker; - static constexpr const int UPDATE_SUCCESS_AND_ACTIVATED = 0; - static constexpr const int CLONE_AND_CHECKOUT_SUCCESS = 0; - static constexpr const int CLONE_AND_CHECKOUT_FAILURE = -3; - static constexpr const int ISMAS_TRIGGER_FAILURE = -5; - static constexpr const int ENVIRONMENT_CONFIG_FAILURE = -6; - static constexpr const int GIT_PULL_FAILURE = -7; - static constexpr const int UPDATE_FILES_FAILURE = -8; - static constexpr const int RSYNC_FAILURE = -9; - static constexpr const int SEND_LAST_VERSION_FAILURE = -10; - static constexpr const int SAVE_LOG_FILES_FAILURE = -11; + explicit UpdateProcessRunning(Worker *worker) : m_worker(worker) { + m_worker->m_updateProcessRunning = true; + emit m_worker->disableExit(); + m_worker->startProgressLoop(); + } + + virtual ~UpdateProcessRunning() { + m_worker->ISMAS() << (m_worker->GUI() << (m_worker->CONSOLE() + << UPDATE_STEP::SEND_LAST_VERSION)); + m_worker->stopProgressLoop(); + + m_worker->m_updateProcessRunning = false; + emit m_worker->enableExit(); + emit m_worker->restartExitTimer(); + } + }; + + friend struct UpdateProcessRunning; public: enum class UPDATE_STEP {