comparison src/blist.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 26eac2362c32
comparison
equal deleted inserted replaced
10398:de59c0e7f87e 10399:aab0c9508318
2382 2382
2383 2383
2384 void gaim_blist_sync() 2384 void gaim_blist_sync()
2385 { 2385 {
2386 FILE *file; 2386 FILE *file;
2387 struct stat st;
2387 const char *user_dir = gaim_user_dir(); 2388 const char *user_dir = gaim_user_dir();
2388 char *filename; 2389 char *filename;
2389 char *filename_real; 2390 char *filename_real;
2390 2391
2391 if (!user_dir) 2392 if (!user_dir)
2414 filename); 2415 filename);
2415 g_free(filename); 2416 g_free(filename);
2416 return; 2417 return;
2417 } 2418 }
2418 2419
2420 if (stat(filename, &st) || (st.st_size == 0)) {
2421 gaim_debug_error("blist", "Failed to save blist\n");
2422 unlink(filename);
2423 g_free(filename);
2424 return;
2425 }
2426
2419 filename_real = g_build_filename(user_dir, "blist.xml", NULL); 2427 filename_real = g_build_filename(user_dir, "blist.xml", NULL);
2420 2428
2421 if (rename(filename, filename_real) < 0) 2429 if (rename(filename, filename_real) < 0)
2422 gaim_debug(GAIM_DEBUG_ERROR, "blist save", 2430 gaim_debug(GAIM_DEBUG_ERROR, "blist save",
2423 "Error renaming %s to %s\n", filename, filename_real); 2431 "Error renaming %s to %s\n", filename, filename_real);
2424
2425 2432
2426 g_free(filename); 2433 g_free(filename);
2427 g_free(filename_real); 2434 g_free(filename_real);
2428 } 2435 }
2429 2436