Prevent data loss in gdesktopappinfo.c

Don't loose the content of mimeapps.list when it doesn't contain
a [Added Associations] group. Pointed out by Alexander Larsson.

https://bugzilla.gnome.org/show_bug.cgi?id=660130
This commit is contained in:
Matthias Clasen 2011-09-29 23:32:20 -04:00
parent e6c76d9fd4
commit 5156d1b2d4

View File

@ -1555,7 +1555,10 @@ update_mimeapps_list (const char *desktop_id,
key_file = g_key_file_new ();
load_succeeded = g_key_file_load_from_file (key_file, filename, G_KEY_FILE_NONE, NULL);
if (!load_succeeded || !g_key_file_has_group (key_file, ADDED_ASSOCIATIONS_GROUP))
if (!load_succeeded ||
(!g_key_file_has_group (key_file, ADDED_ASSOCIATIONS_GROUP) &&
!g_key_file_has_group (key_file, REMOVED_ASSOCIATIONS_GROUP) &&
!g_key_file_has_group (key_file, DEFAULT_APPLICATIONS_GROUP)))
{
g_key_file_free (key_file);
key_file = g_key_file_new ();