mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-14 05:43:02 +01:00
Another logging fix
When renaming a log file, if the new name already exists we just start appending to it and delete the old file. There's no need to create a backup. This fixes an issue where leaving and rejoining the same group multiple times will eventually lead to the logger not working due to trying to use the same file name over and over again.
This commit is contained in:
parent
3f2826bd66
commit
c4c0c0d1f4
15
src/log.c
15
src/log.c
@ -358,19 +358,8 @@ int rename_logfile(const char *src, const char *dest, const char *selfkey, const
|
||||
}
|
||||
|
||||
if (file_exists(newpath)) {
|
||||
char new_backup[MAX_STR_SIZE + 4];
|
||||
snprintf(new_backup, sizeof(new_backup), "%s.old", newpath);
|
||||
|
||||
if (file_exists(new_backup)) {
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
if (rename(newpath, new_backup) != 0) {
|
||||
goto on_error;
|
||||
}
|
||||
}
|
||||
|
||||
if (rename(oldpath, newpath) != 0) {
|
||||
remove(oldpath);
|
||||
} else if (rename(oldpath, newpath) != 0) {
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user