Skip to content

Commit

Permalink
Fix crash when deleting config files fails
Browse files Browse the repository at this point in the history
fixes #12860
  • Loading branch information
gunnarbeutner committed Oct 17, 2016
1 parent 6dbf51a commit 86d14ed
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/remote/configobjectutility.cpp
Expand Up @@ -136,7 +136,7 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full

if (!ConfigItem::CommitItems(ascope.GetContext(), upq, newItems) || !ConfigItem::ActivateItems(upq, newItems, true)) {
if (errors) {
if (unlink(path.CStr()) < 0) {
if (unlink(path.CStr()) < 0 && errno != ENOENT) {
BOOST_THROW_EXCEPTION(posix_error()
<< boost::errinfo_api_function("unlink")
<< boost::errinfo_errno(errno)
Expand All @@ -155,7 +155,7 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
} catch (const std::exception& ex) {
delete expr;

if (unlink(path.CStr()) < 0) {
if (unlink(path.CStr()) < 0 && errno != ENOENT) {
BOOST_THROW_EXCEPTION(posix_error()
<< boost::errinfo_api_function("unlink")
<< boost::errinfo_errno(errno)
Expand Down Expand Up @@ -217,7 +217,7 @@ bool ConfigObjectUtility::DeleteObjectHelper(const ConfigObject::Ptr& object, bo
String path = GetObjectConfigPath(object->GetReflectionType(), object->GetName());

if (Utility::PathExists(path)) {
if (unlink(path.CStr()) < 0) {
if (unlink(path.CStr()) < 0 && errno != ENOENT) {
BOOST_THROW_EXCEPTION(posix_error()
<< boost::errinfo_api_function("unlink")
<< boost::errinfo_errno(errno)
Expand Down

0 comments on commit 86d14ed

Please sign in to comment.