diff --git a/worker.cpp b/worker.cpp index 5137b3f..92b2952 100644 --- a/worker.cpp +++ b/worker.cpp @@ -251,149 +251,6 @@ bool Worker::repairCorruptedRepository() { return true; } -#if 0 -int Worker::sendCloneAndCheckoutFailure() { - m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_FAILURE, - QString("CLONE OR CHECKOUT FAILED: ") + m_customerRepository); - IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, - QString("#M=APISM#C=CMD_EVENT#J=") + - m_ismasClient.errorGitClone(m_updateStatus.m_statusDescription)); - - return CLONE_AND_CHECKOUT_FAILURE; -} - -int Worker::sendCloneAndCheckoutSuccess() { - m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_SUCCESS, - QString("CLONED REPOSITORY %1 AND CHECKED OUT BRANCH %2") - .arg(m_customerRepository) - .arg(m_gc.branchName())); - - IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, - QString("#M=APISM#C=CMD_EVENT#J=") + - m_ismasClient.cloneAndCheckoutCustomerRepository( - m_updateStatus.m_statusDescription)); - - return CLONE_AND_CHECKOUT_SUCCESS; -} - -int Worker::sendIsmasTriggerFailure() { - m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET_FAILURE, - QString("ISMAS update trigger wrong")); - IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, - QString("#M=APISM#C=CMD_EVENT#J=") + - m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR, - "CHECK-UPDATE-TRIGGER", - m_updateStatus.m_statusDescription)); - return ISMAS_TRIGGER_FAILURE; -} - -int Worker::sendCustomerEnvironmentConfigurationFailed() { - m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH_FAILURE, - QString("Configuring customer environment failed")); - IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, - QString("#M=APISM#C=CMD_EVENT#J=") + - m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR, - "GIT-CHECKOUT-BRANCH", - m_updateStatus.m_statusDescription)); - return ENVIRONMENT_CONFIG_FAILURE; -} - -int Worker::sendPullFailure() { - m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE, - QString("No files to update")); - IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, - QString("#M=APISM#C=CMD_EVENT#J=") + - m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR, - "FETCH-FILES-TO-UPDATE", - m_updateStatus.m_statusDescription)); - return GIT_PULL_FAILURE; -} - -int Worker::sendFileUpdateFailure() { - m_updateStatus = UpdateStatus(UPDATE_STATUS::PSA_UPDATE_FILES_FAILED, - QString("Updating files failed")); - IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, - QString("#M=APISM#C=CMD_EVENT#J=") + - m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR, - "UPDATE-FILES", - m_updateStatus.m_statusDescription)); - return UPDATE_FILES_FAILURE; -} - -int Worker::sendRsyncFailure() { - m_updateStatus = UpdateStatus(UPDATE_STATUS::RSYNC_UPDATES_FAILURE, - QString("Syncing files to update failed")); - IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, - QString("#M=APISM#C=CMD_EVENT#J=") + - m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR, - "RSYNC-UPDATE-FILES", - m_updateStatus.m_statusDescription)); - - return RSYNC_FAILURE; -} - -int Worker::sendLastVersionFailure() { - m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_SEND_LAST_VERSION_FAILED, - QString("Sending ISMAS last version failed")); - IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, - QString("#M=APISM#C=CMD_EVENT#J=") + - m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR, - "ISMAS-SEND-LAST-VERSION", - m_updateStatus.m_statusDescription)); - return SEND_LAST_VERSION_FAILURE; -} - -int Worker::sendSaveLogFilesFailure() { - m_updateStatus = UpdateStatus(UPDATE_STATUS::SAVE_LOG_FILES_FAILED, - QString("Saving log files failed")); - IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, - QString("#M=APISM#C=CMD_EVENT#J=") + - m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR, - "SAVE-LOG-FILES", - m_updateStatus.m_statusDescription)); - return SAVE_LOG_FILES_FAILURE; -} - -int Worker::sendFoundFilesToUpdateSuccess() { - m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECK_FILES_TO_UPDATE_SUCCESS, - QString("Files to update: ") + m_filesToUpdate.join(',')); - IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, - QString("#M=APISM#C=CMD_EVENT#J=") + - m_ismasClient.updateOfPSAContinues("CHECK-FILES-TO-UPDATE", - m_updateStatus.m_statusDescription)); - return 0; -} - -int Worker::sendUpdateSucceededAndActivated() { - ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::UPDATE_SUCCEEDED)); - ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::UPDATE_ACTIVATED)); - //IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, - // QString("#M=APISM#C=CMD_EVENT#J=") + - // m_ismasClient.updateOfPSASucceeded("")); - - //m_ismasClient.setProgressInPercent(100); - - // mark update as activated -> this resets the WAIT button - //IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, - // QString("#M=APISM#C=CMD_EVENT#J=") + - // m_ismasClient.updateOfPSAActivated()); - - return UPDATE_SUCCESS_AND_ACTIVATED; -} -int Worker::sendFinalResult() { - m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_SUCCESS, - QString("Update process succeeded. Reset WAIT.")); - if (std::optional s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::SUCCESS, - m_updateStatus.m_statusDescription)) { - IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, - QString("#M=APISM#C=CMD_EVENT#J=") + s.value()); - } - - return 0; -} - -#endif - void Worker::privateUpdate() { if (!m_mainWindow) { Utils::printCriticalErrorMsg("m_mainWindow NOT SET"); @@ -779,14 +636,15 @@ bool Worker::filesToUpdate() { if (!changes.value().contains("Already up to date")) { if (std::optional changedFileNames = m_gc.gitDiff(changes.value())) { m_filesToUpdate << changedFileNames.value(); - m_filesToUpdate.removeDuplicates(); } } GUI() << (CONSOLE(m_filesToUpdate) << UPDATE_STEP::FILES_TO_UPDATE); } else { ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::UPDATE_REPOSITORY_FAILURE)); + return false; } + m_filesToUpdate.removeDuplicates(); return true; }