From fc2e9cc6980c161ac44a49901e2dfb1181a3e150 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Fri, 17 Oct 2014 16:39:30 +0200 Subject: [PATCH] Do not delete collections if a broker is configured (win32). --- pandora_agents/win32/pandora_agent_conf.cc | 13 +++++++++++++ pandora_agents/win32/pandora_agent_conf.h | 2 ++ pandora_agents/win32/pandora_windows_service.cc | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/pandora_agents/win32/pandora_agent_conf.cc b/pandora_agents/win32/pandora_agent_conf.cc index e7b19fb4ba..b1e38d8d30 100644 --- a/pandora_agents/win32/pandora_agent_conf.cc +++ b/pandora_agents/win32/pandora_agent_conf.cc @@ -33,6 +33,7 @@ using namespace Pandora_Strutils; Pandora::Pandora_Agent_Conf::Pandora_Agent_Conf () { this->key_values = NULL; this->collection_list = NULL; + this->broker_enabled = false; } /** @@ -202,6 +203,7 @@ Pandora::Pandora_Agent_Conf::setFile (string *all_conf){ string path_broker, name_broker; int pos_c; int position = 0; + this->broker_enabled = true; name_broker = buffer.substr(pos+13); path_broker = name_broker+".conf"; @@ -460,3 +462,14 @@ bool Pandora::Pandora_Agent_Conf::isLastCollection() { return collection_it == collection_list->end(); } + +/** + * Check whether there are broker agents configured. + * + * @return True if there is at least one broker agent. + * + */ +bool +Pandora::Pandora_Agent_Conf::isBrokerEnabled() { + return this->broker_enabled; +} diff --git a/pandora_agents/win32/pandora_agent_conf.h b/pandora_agents/win32/pandora_agent_conf.h index 957e028756..f22819450e 100644 --- a/pandora_agents/win32/pandora_agent_conf.h +++ b/pandora_agents/win32/pandora_agent_conf.h @@ -45,6 +45,7 @@ namespace Pandora { list *key_values; list *collection_list; list::iterator collection_it; + bool broker_enabled; Pandora_Agent_Conf (); public: @@ -64,6 +65,7 @@ namespace Pandora { bool isLastCollection (); bool isInCollectionList(string name); + bool isBrokerEnabled (); }; } diff --git a/pandora_agents/win32/pandora_windows_service.cc b/pandora_agents/win32/pandora_windows_service.cc index 13498db9d3..bb51b494cf 100644 --- a/pandora_agents/win32/pandora_windows_service.cc +++ b/pandora_agents/win32/pandora_windows_service.cc @@ -1083,6 +1083,11 @@ Pandora_Windows_Service::purgeDiskCollections () { struct stat file; string tmp, filepath; + /*Do not delete collections if there is a broker agent*/ + if (conf->isBrokerEnabled()) { + return; + } + filepath = Pandora::getPandoraInstallDir() +"collections\\"; /*Open the directory*/ dir = opendir (filepath.c_str ());