Fix exception in PerfdataWriter::RotateFile

fixes #11801
This commit is contained in:
Gunnar Beutner 2016-05-18 14:01:32 +02:00
parent 222b90107f
commit bb69540b32
1 changed files with 8 additions and 6 deletions

View 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));
}
}
}