1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-22 21:53:05 +01:00

Fix bug causing profile to be overwritten under a rare condition

This commit is contained in:
Jfreegman 2015-11-05 16:15:59 -05:00
parent f707dce2da
commit a95fc7824c
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63

View File

@ -889,7 +889,7 @@ void *thread_cqueue(void *data)
void *thread_av(void *data) void *thread_av(void *data)
{ {
ToxAV *av = (ToxAV *) data; ToxAV *av = (ToxAV *) data;
while (true) { while (true) {
pthread_mutex_lock(&Winthread.lock); pthread_mutex_lock(&Winthread.lock);
toxav_iterate(av); toxav_iterate(av);
@ -1101,6 +1101,9 @@ static int rename_old_profile(const char *user_config_dir)
if (!file_exists(old_data_file)) if (!file_exists(old_data_file))
return 0; return 0;
if (file_exists(DATA_FILE))
return 0;
if (rename(old_data_file, DATA_FILE) != 0) if (rename(old_data_file, DATA_FILE) != 0)
return -1; return -1;
@ -1112,6 +1115,9 @@ static int rename_old_profile(const char *user_config_dir)
if (!file_exists(old_data_blocklist)) if (!file_exists(old_data_blocklist))
return 0; return 0;
if (file_exists(BLOCK_FILE))
return 0;
if (rename(old_data_blocklist, BLOCK_FILE) != 0) if (rename(old_data_blocklist, BLOCK_FILE) != 0)
return -1; return -1;
@ -1276,7 +1282,7 @@ int main(int argc, char **argv)
#ifdef AUDIO #ifdef AUDIO
av = init_audio(prompt, m); av = init_audio(prompt, m);
#ifdef VIDEO #ifdef VIDEO
init_video(prompt, m); init_video(prompt, m);