From: Gunnar Beutner Date: Wed, 18 May 2016 12:01:32 +0000 (+0200) Subject: Fix exception in PerfdataWriter::RotateFile X-Git-Tag: v2.4.9~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0e76876228fadda025b0e1ac4b82e37b96f384e9;p=icinga2 Fix exception in PerfdataWriter::RotateFile fixes #11801 --- 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)); + } } }