ApiListener#RotateLogFile(): don't overwrite previous log

(cherry picked from commit 997d84bfa0)
This commit is contained in:
Alexander A. Klimov 2019-04-17 14:31:49 +02:00 committed by Michael Friedrich
parent 206fb222c0
commit c55e4e122f
1 changed files with 5 additions and 7 deletions

View File

@ -1095,13 +1095,11 @@ void ApiListener::RotateLogFile()
String oldpath = GetApiDir() + "log/current";
String newpath = GetApiDir() + "log/" + Convert::ToString(static_cast<int>(ts)+1);
#ifdef _WIN32
_unlink(newpath.CStr());
#endif /* _WIN32 */
(void) rename(oldpath.CStr(), newpath.CStr());
// If the log is being rotated more than once per second,
// don't overwrite the previous one, but silently deny rotation.
if (!Utility::PathExists(newpath)) {
(void) rename(oldpath.CStr(), newpath.CStr());
}
}
void ApiListener::LogGlobHandler(std::vector<int>& files, const String& file)