From b2364884d87dd59737b36a422e30ff1f11c40b33 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 11 Nov 2015 10:25:18 +0100 Subject: [PATCH] Check whether config file exists before trying to create object fixes #10602 --- lib/remote/configobjectutility.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/remote/configobjectutility.cpp b/lib/remote/configobjectutility.cpp index d6270baad..1747fe71f 100644 --- a/lib/remote/configobjectutility.cpp +++ b/lib/remote/configobjectutility.cpp @@ -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(); -- 2.40.0