From 0e76876228fadda025b0e1ac4b82e37b96f384e9 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 18 May 2016 14:01:32 +0200 Subject: [PATCH] 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 7760045ec..304ce2605 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)); + } } } -- 2.40.0