mirror of https://github.com/Icinga/icinga2.git
Check whether config file exists before trying to create object
fixes #10602
This commit is contained in:
parent
e3c75faabc
commit
b2364884d8
|
@ -111,6 +111,9 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
|
|||
String path = GetObjectConfigPath(type, fullName);
|
||||
Utility::MkDirP(Utility::DirName(path), 0700);
|
||||
|
||||
if (Utility::PathExists(path))
|
||||
BOOST_THROW_EXCEPTION(ScriptError("Configuration file '" + path + "' already exists."));
|
||||
|
||||
std::ofstream fp(path.CStr(), std::ofstream::out | std::ostream::trunc);
|
||||
fp << config;
|
||||
fp.close();
|
||||
|
|
Loading…
Reference in New Issue