comparison src/prefs.c @ 10399:aab0c9508318

[gaim-migrate @ 11630] Don't erase prefs/accounts/blist/pounces if we failed to write the new file to disk - this fixes the "Gaim lost all my settings when my disk/quota filled up" bugs. committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Sun, 19 Dec 2004 17:35:59 +0000
parents c432b927b0b1
children 3232e1a33899
comparison
equal deleted inserted replaced
10398:de59c0e7f87e 10399:aab0c9508318
794 } 794 }
795 } 795 }
796 796
797 void gaim_prefs_sync() { 797 void gaim_prefs_sync() {
798 FILE *file; 798 FILE *file;
799 struct stat st;
799 const char *user_dir = gaim_user_dir(); 800 const char *user_dir = gaim_user_dir();
800 char *filename; 801 char *filename;
801 char *filename_real; 802 char *filename_real;
802 803
803 if(!prefs_is_loaded) { 804 if(!prefs_is_loaded) {
824 fclose(file); 825 fclose(file);
825 chmod(filename, S_IRUSR | S_IWUSR); 826 chmod(filename, S_IRUSR | S_IWUSR);
826 } else { 827 } else {
827 gaim_debug(GAIM_DEBUG_ERROR, "prefs", "Unable to write %s\n", 828 gaim_debug(GAIM_DEBUG_ERROR, "prefs", "Unable to write %s\n",
828 filename); 829 filename);
830 g_free(filename);
831 return;
832 }
833
834 if (stat(filename, &st) || (st.st_size == 0)) {
835 gaim_debug_error("prefs", "Failed to save prefs\n");
836 unlink(filename);
829 g_free(filename); 837 g_free(filename);
830 return; 838 return;
831 } 839 }
832 840
833 filename_real = g_build_filename(user_dir, "prefs.xml", NULL); 841 filename_real = g_build_filename(user_dir, "prefs.xml", NULL);