mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 01:43:01 +01:00
fix for issue #254
This commit is contained in:
parent
773a75b948
commit
48cf4ebf02
12
src/log.c
12
src/log.c
@ -89,8 +89,8 @@ static int init_logging_session(char *name, const char *selfkey, const char *oth
|
||||
snprintf(log_path, sizeof(log_path), "%s%s%s-%s%s%s.log", user_config_dir, LOGDIR, self_id, name, namedash, other_id);
|
||||
|
||||
free(user_config_dir);
|
||||
|
||||
log->file = fopen(log_path, "a+");
|
||||
|
||||
snprintf(log->path, sizeof(log->path), "%s", log_path);
|
||||
|
||||
if (log->file == NULL)
|
||||
@ -160,7 +160,7 @@ void load_chat_history(ToxWindow *self, struct chatlog *log)
|
||||
struct stat st;
|
||||
|
||||
if (stat(log->path, &st) == -1) {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, "* Failed to stat log file");
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, " * Failed to stat log file");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -174,9 +174,15 @@ void load_chat_history(ToxWindow *self, struct chatlog *log)
|
||||
if (hstbuf == NULL)
|
||||
exit_toxic_err("failed in load_chat_history", FATALERR_MEMORY);
|
||||
|
||||
if (fseek(log->file, 0L, SEEK_SET) == -1) {
|
||||
free(hstbuf);
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, " * Failed to read log file");
|
||||
return;
|
||||
}
|
||||
|
||||
if (fread(hstbuf, sz, 1, log->file) != 1) {
|
||||
free(hstbuf);
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, "* Failed to read log file");
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, " * Failed to read log file");
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user