Commit dd962c04 authored by Daniele Kruse's avatar Daniele Kruse
Browse files

The deletion of the mock name server path in the destructor occurs only if the...

The deletion of the mock name server path in the destructor occurs only if the object was created using the empty constructor (this is what happens in unit tests)
parent bbc90b65
......@@ -294,7 +294,7 @@ void cta::MockNameServer::deleteTapeFile(const SecurityIdentity &requester, cons
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::MockNameServer::MockNameServer(): m_fileIdCounter(0) {
cta::MockNameServer::MockNameServer(): m_fileIdCounter(0), m_deleteOnExit(true) {
umask(0);
char path[100];
strncpy(path, "/tmp/CTATmpFsXXXXXX", 100);
......@@ -312,7 +312,7 @@ cta::MockNameServer::MockNameServer(): m_fileIdCounter(0) {
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::MockNameServer::MockNameServer(const std::string &path): m_fileIdCounter(0) {
cta::MockNameServer::MockNameServer(const std::string &path): m_fileIdCounter(0), m_deleteOnExit(false) {
Utils::assertAbsolutePathSyntax(path);
assertFsDirExists(path);
m_fsDir = path;
......@@ -322,6 +322,11 @@ cta::MockNameServer::MockNameServer(const std::string &path): m_fileIdCounter(0)
// destructor
//------------------------------------------------------------------------------
cta::MockNameServer::~MockNameServer() throw() {
if(m_deleteOnExit) {
std::string cmd("rm -rf ");
cmd += m_fsDir;
system(cmd.c_str());
}
}
//------------------------------------------------------------------------------
......
......@@ -240,6 +240,11 @@ private:
* Mutex to serialize access to the file system modification functions
*/
std::mutex m_mutex;
/**
* Flag that determines whether the base path of the mock name server needs to be deleted by the destructor
*/
bool m_deleteOnExit;
}; // class MockNameServer
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment