From 3c2acab7d7ebf12947f31d9aac1a0fc0343620b0 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 7 Aug 2012 14:17:36 +0200 Subject: [PATCH] Fixed log message incorrectly referring to temp file. --- base/dynamicobject.cpp | 6 +++++- icinga/icingaapplication.cpp | 4 +--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/base/dynamicobject.cpp b/base/dynamicobject.cpp index 1995808ad..fd7c81316 100644 --- a/base/dynamicobject.cpp +++ b/base/dynamicobject.cpp @@ -352,8 +352,10 @@ void DynamicObject::DumpObjects(const String& filename) { Logger::Write(LogInformation, "base", "Dumping program state to file '" + filename + "'"); + String tempFilename = filename + ".tmp"; + ofstream fp; - fp.open(filename.CStr()); + fp.open(tempFilename.CStr()); if (!fp) throw_exception(runtime_error("Could not open '" + filename + "' file")); @@ -403,6 +405,8 @@ void DynamicObject::DumpObjects(const String& filename) } } } + + rename(tempFilename.CStr(), filename.CStr()); } void DynamicObject::RestoreObjects(const String& filename) diff --git a/icinga/icingaapplication.cpp b/icinga/icingaapplication.cpp index 37336d48f..937fd2473 100644 --- a/icinga/icingaapplication.cpp +++ b/icinga/icingaapplication.cpp @@ -208,9 +208,7 @@ int IcingaApplication::Main(const vector& args) } void IcingaApplication::DumpProgramState(void) { - String temp = GetStatePath() + ".tmp"; - DynamicObject::DumpObjects(temp); - rename(temp.CStr(), GetStatePath().CStr()); + DynamicObject::DumpObjects(GetStatePath()); } IcingaApplication::Ptr IcingaApplication::GetInstance(void) -- 2.40.0