From 52606513ffb52eb14366a3d2a1a75b4fda265521 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 31 Aug 2025 16:24:57 +1200 Subject: [PATCH] feat: Update 3 files --- source/src/commands/destroy.cpp | 23 ++++++++++++++++++----- source/src/commands/restoredata.cpp | 15 ++++++++------- source/src/commands/shared_commands.hpp | 2 ++ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/source/src/commands/destroy.cpp b/source/src/commands/destroy.cpp index 6eef57b..b17ba3f 100644 --- a/source/src/commands/destroy.cpp +++ b/source/src/commands/destroy.cpp @@ -49,8 +49,7 @@ namespace dropshell namespace shared_commands { - - bool destroy_service(const std::string &server, const std::string &service) + bool destroy_service_remote(const std::string &server, const std::string &service) { ServerConfig server_env(server); @@ -120,6 +119,11 @@ namespace dropshell else error << "No valid local server information for server " << server << std::endl; + return true; + } + + bool destroy_service_local(const std::string &server, const std::string &service) + { // step 2 - destroy the local service directory, if it exists. std::string local_service_path = localpath::service(server, service); if (local_service_path.empty() || !std::filesystem::exists(local_service_path)) @@ -134,11 +138,20 @@ namespace dropshell else info << "Local service directory removed: " << local_service_path << std::endl; } - - info << "Finished destroying service " << service << " on server " << server << std::endl; - return true; } + + bool destroy_service(const std::string &server, const std::string &service) + { + if (!destroy_service_remote(server, service)) + return false; + if (!destroy_service_local(server, service)) + return false; + + info << "Finished destroying service " << service << " on server " << server << std::endl; + return true; + } + } // namespace shared_commands int destroy_handler(const CommandContext &ctx) diff --git a/source/src/commands/restoredata.cpp b/source/src/commands/restoredata.cpp index 1cb5636..b67da88 100644 --- a/source/src/commands/restoredata.cpp +++ b/source/src/commands/restoredata.cpp @@ -186,16 +186,17 @@ namespace dropshell } { // Destroy the old service - info << "2) Destroying old service..." << std::endl; - if (!shared_commands::destroy_service(server, service)) + info << "2) Destroying old remote service..." << std::endl; + if (!shared_commands::destroy_service_remote(server, service)) return 1; + info << "Remote service destroyed." << std::endl; } - { // create the new service - info << "3) Creating new service..." << std::endl; - if (!shared_commands::create_service(server, service_info.template_name, service, service_info.user)) - return 1; - } + // { // create the new service + // info << "3) Creating new service..." << std::endl; + // if (!shared_commands::create_service(server, service_info.template_name, service, service_info.user)) + // return 1; + // } { // installing fresh service info << "4) Install of fresh service..." << std::endl; diff --git a/source/src/commands/shared_commands.hpp b/source/src/commands/shared_commands.hpp index b5cead3..043a6ec 100644 --- a/source/src/commands/shared_commands.hpp +++ b/source/src/commands/shared_commands.hpp @@ -104,6 +104,8 @@ namespace dropshell bool uninstall_service(const ServerConfig &server_env, const std::string &service); // defined in destroy.cpp + bool destroy_service_remote(const std::string &server, const std::string &service); + bool destroy_service_local(const std::string &server, const std::string &service); bool destroy_service(const std::string &server, const std::string &service); // defined in install.cpp