Do not delete collections if a broker is configured (win32).

This commit is contained in:
Ramon Novoa 2014-10-17 16:39:30 +02:00
parent a10f2a6d2e
commit 1f4f9d8cb3
3 changed files with 20 additions and 0 deletions

View File

@ -33,6 +33,7 @@ using namespace Pandora_Strutils;
Pandora::Pandora_Agent_Conf::Pandora_Agent_Conf () { Pandora::Pandora_Agent_Conf::Pandora_Agent_Conf () {
this->key_values = NULL; this->key_values = NULL;
this->collection_list = 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; string path_broker, name_broker;
int pos_c; int pos_c;
int position = 0; int position = 0;
this->broker_enabled = true;
name_broker = buffer.substr(pos+13); name_broker = buffer.substr(pos+13);
path_broker = name_broker+".conf"; path_broker = name_broker+".conf";
@ -460,3 +462,14 @@ bool
Pandora::Pandora_Agent_Conf::isLastCollection() { Pandora::Pandora_Agent_Conf::isLastCollection() {
return collection_it == collection_list->end(); 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;
}

View File

@ -45,6 +45,7 @@ namespace Pandora {
list<Key_Value> *key_values; list<Key_Value> *key_values;
list<Collection> *collection_list; list<Collection> *collection_list;
list<Collection>::iterator collection_it; list<Collection>::iterator collection_it;
bool broker_enabled;
Pandora_Agent_Conf (); Pandora_Agent_Conf ();
public: public:
@ -64,6 +65,7 @@ namespace Pandora {
bool isLastCollection (); bool isLastCollection ();
bool isInCollectionList(string name); bool isInCollectionList(string name);
bool isBrokerEnabled ();
}; };
} }

View File

@ -1083,6 +1083,11 @@ Pandora_Windows_Service::purgeDiskCollections () {
struct stat file; struct stat file;
string tmp, filepath; string tmp, filepath;
/*Do not delete collections if there is a broker agent*/
if (conf->isBrokerEnabled()) {
return;
}
filepath = Pandora::getPandoraInstallDir() +"collections\\"; filepath = Pandora::getPandoraInstallDir() +"collections\\";
/*Open the directory*/ /*Open the directory*/
dir = opendir (filepath.c_str ()); dir = opendir (filepath.c_str ());