[icinga-checkins] icinga.org: icinga2/master: Fix exception in PerfdataWriter::RotateFile

git at icinga.org git at icinga.org
Wed May 18 14:31:33 CEST 2016


Module: icinga2
Branch: master
Commit: bb69540b32c833720ed69318fb04572e64ffaee7
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=bb69540b32c833720ed69318fb04572e64ffaee7

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Wed May 18 14:01:32 2016 +0200

Fix exception in PerfdataWriter::RotateFile

fixes #11801

---

 lib/perfdata/perfdatawriter.cpp |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lib/perfdata/perfdatawriter.cpp b/lib/perfdata/perfdatawriter.cpp
index 7760045..304ce26 100644
--- a/lib/perfdata/perfdatawriter.cpp
+++ b/lib/perfdata/perfdatawriter.cpp
@@ -123,12 +123,14 @@ void PerfdataWriter::RotateFile(std::ofstream& output, const String& temp_path,
 	if (output.good()) {
 		output.close();
 
-		String finalFile = perfdata_path + "." + Convert::ToString((long)Utility::GetTime());
-		if (rename(temp_path.CStr(), finalFile.CStr()) < 0) {
-			BOOST_THROW_EXCEPTION(posix_error()
-			    << boost::errinfo_api_function("rename")
-			    << boost::errinfo_errno(errno)
-			    << boost::errinfo_file_name(temp_path));
+		if (Utility::PathExists(temp_path)) {
+			String finalFile = perfdata_path + "." + Convert::ToString((long)Utility::GetTime());
+			if (rename(temp_path.CStr(), finalFile.CStr()) < 0) {
+				BOOST_THROW_EXCEPTION(posix_error()
+				    << boost::errinfo_api_function("rename")
+				    << boost::errinfo_errno(errno)
+				    << boost::errinfo_file_name(temp_path));
+			}
 		}
 	}
 



More information about the icinga-checkins mailing list