# HG changeset patch # User Sean Egan # Date 1083011611 0 # Node ID c0f5132fd5a39ea69a4ae04b2c3f38ac970a36d3 # Parent 190a5f7f95245e6c401dbcca5eaee5d684c926c0 [gaim-migrate @ 9590] If you're careless like me, and screw up hand-editing your blist.xml you won't be in the same boat I am, having your entire blist obliterated as this commit will back the file up to blist.xml~ before obliterating it. committer: Tailor Script diff -r 190a5f7f9524 -r c0f5132fd5a3 src/blist.c --- a/src/blist.c Mon Apr 26 19:19:14 2004 +0000 +++ b/src/blist.c Mon Apr 26 20:33:31 2004 +0000 @@ -2137,14 +2137,29 @@ } gaim = xmlnode_from_str(contents, length); - g_free(contents); - + if(!gaim) { + FILE *backup; + char *name; gaim_debug(GAIM_DEBUG_ERROR, "blist import", "Error parsing %s\n", filename); + name = g_build_filename(gaim_user_dir(), "blist.xml~", NULL); + + if((backup = fopen(name, "w"))) { + fwrite(contents, length, 1, backup); + fclose(backup); + chmod(name, S_IRUSR | S_IWUSR); + } else { + gaim_debug(GAIM_DEBUG_ERROR, "blist load", "Unable to write backup %s\n", + name); + } + g_free(name); + g_free(contents); return FALSE; } - + + g_free(contents); + blist = xmlnode_get_child(gaim, "blist"); if(blist) { xmlnode *groupnode; @@ -2218,7 +2233,8 @@ if(g_file_test(filename, G_FILE_TEST_EXISTS)) { if(!gaim_blist_read(filename)) { msg = g_strdup_printf(_("An error was encountered parsing your " - "buddy list. It has not been loaded.")); + "buddy list. It has not been loaded, " + "and the old file has moved to blist.xml~.")); gaim_notify_error(NULL, NULL, _("Buddy List Error"), msg); g_free(msg); }