summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2022-05-18 18:05:16 +0200
committerMilan Crha <mcrha@redhat.com>2022-05-18 18:41:47 +0200
commit1a1e37a12e137891ac09e098491e5e054108af61 (patch)
tree8c4fa852b2644e436a5fbd2e1e03874c56d7a068
parent3a6f513663534154d53223f00561f37386264041 (diff)
downloadevolution-data-server-1a1e37a12e137891ac09e098491e5e054108af61.tar.gz
GOA module: Prevent ESource removal on D-Bus reconnect or registry reload
The GOA module is persistent between evolution-source-registry reloads, which means its `goa_to_eds` hash table could be left filled when the gnome_online_accounts_populate_accounts_table() is called, thus it could remove existing ESource-s, because it looked like the GOA account ID is used by a different ESource. The gnome_online_accounts_populate_accounts_table() is called when establishing a connection to the goa-daemon, which can also happen during runtime.
-rw-r--r--src/modules/gnome-online-accounts/module-gnome-online-accounts.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/modules/gnome-online-accounts/module-gnome-online-accounts.c b/src/modules/gnome-online-accounts/module-gnome-online-accounts.c
index 03c4930f5..b05dd59c2 100644
--- a/src/modules/gnome-online-accounts/module-gnome-online-accounts.c
+++ b/src/modules/gnome-online-accounts/module-gnome-online-accounts.c
@@ -1154,11 +1154,14 @@ gnome_online_accounts_populate_accounts_table (EGnomeOnlineAccounts *extension,
e_goa_debug_printf ("Found %d existing sources\n", g_list_length (list));
+ g_hash_table_remove_all (extension->goa_to_eds);
+
for (link = list; link != NULL; link = g_list_next (link)) {
ESource *source;
ESourceGoa *goa_ext;
const gchar *account_id;
const gchar *source_uid;
+ const gchar *existing_source_uid;
GList *match;
source = E_SOURCE (link->data);
@@ -1173,14 +1176,20 @@ gnome_online_accounts_populate_accounts_table (EGnomeOnlineAccounts *extension,
continue;
}
- if (g_hash_table_lookup (extension->goa_to_eds, account_id)) {
- e_goa_debug_printf ("Source '%s' references account '%s' which is already used by other source\n",
- source_uid, account_id);
-
- /* There are more ESource-s referencing the same GOA account;
- delete the later. */
- g_queue_push_tail (&trash, source);
- continue;
+ existing_source_uid = g_hash_table_lookup (extension->goa_to_eds, account_id);
+ if (existing_source_uid) {
+ if (g_strcmp0 (source_uid, existing_source_uid) == 0) {
+ e_goa_debug_printf ("Already know the source '%s' references account '%s'\n",
+ source_uid, account_id);
+ } else {
+ e_goa_debug_printf ("Source '%s' references account '%s' which is already used by source '%s'\n",
+ source_uid, account_id, existing_source_uid);
+
+ /* There are more ESource-s referencing the same GOA account;
+ delete the later. */
+ g_queue_push_tail (&trash, source);
+ continue;
+ }
}
/* Verify the GOA account still exists. */