1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-12-23 04:03:25 +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:
jfreegman 2020-11-24 21:47:21 -05:00
parent 3f2826bd66
commit c4c0c0d1f4
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63

View File

@ -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;
}