comparison src/pounce.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 0ad01d743f60
children bed2c96bc1fb
comparison
equal deleted inserted replaced
10398:de59c0e7f87e 10399:aab0c9508318
844 844
845 void 845 void
846 gaim_pounces_sync(void) 846 gaim_pounces_sync(void)
847 { 847 {
848 FILE *fp; 848 FILE *fp;
849 struct stat st;
849 const char *user_dir = gaim_user_dir(); 850 const char *user_dir = gaim_user_dir();
850 char *filename; 851 char *filename;
851 char *filename_real; 852 char *filename_real;
852 853
853 if (!pounces_loaded) { 854 if (!pounces_loaded) {
886 chmod(filename, S_IRUSR | S_IWUSR); 887 chmod(filename, S_IRUSR | S_IWUSR);
887 } 888 }
888 else { 889 else {
889 gaim_debug(GAIM_DEBUG_ERROR, "pounces", "Unable to write %s\n", 890 gaim_debug(GAIM_DEBUG_ERROR, "pounces", "Unable to write %s\n",
890 filename); 891 filename);
892 g_free(filename);
893 return;
894 }
895
896 if (stat(filename, &st) || (st.st_size == 0)) {
897 gaim_debug_error("pounces", "Failed to save pounces\n");
898 unlink(filename);
891 g_free(filename); 899 g_free(filename);
892 return; 900 return;
893 } 901 }
894 902
895 filename_real = g_build_filename(user_dir, "pounces.xml", NULL); 903 filename_real = g_build_filename(user_dir, "pounces.xml", NULL);