]> granicus.if.org Git - icinga2/commitdiff
Fix exception in PerfdataWriter::RotateFile
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 18 May 2016 12:01:32 +0000 (14:01 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Thu, 19 May 2016 07:50:55 +0000 (09:50 +0200)
fixes #11801

lib/perfdata/perfdatawriter.cpp

index 7760045ec372ddbf20e46a000eac1879f0dd03e2..304ce2605c44a901a9f3eaebfe25d2e9e7136fb7 100644 (file)
@@ -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));
+                       }
                }
        }