mirror of https://github.com/Icinga/icinga2.git
API: Fix error message with PUT requests for existing objects
fixes #11396
This commit is contained in:
parent
b8e911b0e5
commit
8a65c4a776
|
@ -111,8 +111,10 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
|
||||||
String path = GetObjectConfigPath(type, fullName);
|
String path = GetObjectConfigPath(type, fullName);
|
||||||
Utility::MkDirP(Utility::DirName(path), 0700);
|
Utility::MkDirP(Utility::DirName(path), 0700);
|
||||||
|
|
||||||
if (Utility::PathExists(path))
|
if (Utility::PathExists(path)) {
|
||||||
BOOST_THROW_EXCEPTION(ScriptError("Configuration file '" + path + "' already exists."));
|
errors->Add("Configuration file '" + path + "' already exists.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::ofstream fp(path.CStr(), std::ofstream::out | std::ostream::trunc);
|
std::ofstream fp(path.CStr(), std::ofstream::out | std::ostream::trunc);
|
||||||
fp << config;
|
fp << config;
|
||||||
|
|
Loading…
Reference in New Issue