[evolution-data-server/gnome-3-36] ECollectionBackend: Limit how often checks for new child sources
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-3-36] ECollectionBackend: Limit how often checks for new child sources
- Date: Thu, 14 May 2020 08:40:21 +0000 (UTC)
commit 798a03d0fa01af9ba6a0418ccb95d9a820c548dc
Author: Milan Crha <mcrha redhat com>
Date: Thu May 14 10:41:11 2020 +0200
ECollectionBackend: Limit how often checks for new child sources
Let it automatically check for new child sources (calendars, task
lists, ...) only once per day. This does not change that often, thus
no need to retry every time the backend goes from offline to online
state.
Related to https://gitlab.gnome.org/GNOME/gnome-online-accounts/-/issues/89
src/libebackend/e-collection-backend.c | 32 +++++++++++++++++++++++++++-----
1 file changed, 27 insertions(+), 5 deletions(-)
---
diff --git a/src/libebackend/e-collection-backend.c b/src/libebackend/e-collection-backend.c
index a1627dc3a..7679accaf 100644
--- a/src/libebackend/e-collection-backend.c
+++ b/src/libebackend/e-collection-backend.c
@@ -73,6 +73,7 @@ struct _ECollectionBackendPrivate {
gulong notify_collection_handler_id;
gulong notify_online_handler_id;
+ gint64 last_populate_call;
guint scheduled_populate_idle_id;
};
@@ -618,16 +619,26 @@ collection_backend_populate_idle_cb (gpointer user_data)
considered new anymore. */
collection_backend_forget_new_sources (backend);
+ backend->priv->last_populate_call = g_get_real_time ();
+
class->populate (backend);
return FALSE;
}
static void
-collection_backend_schedule_populate_idle (ECollectionBackend *backend)
+collection_backend_schedule_populate_idle (ECollectionBackend *backend,
+ gboolean force)
{
g_return_if_fail (E_IS_COLLECTION_BACKEND (backend));
+ if (!force) {
+ /* Let automatically check for new child sources only once per day.
+ Users can still force this manually using e_source_registry_refresh_backend(). */
+ if (g_get_real_time () - backend->priv->last_populate_call < G_USEC_PER_SEC * 60L * 60L * 24L)
+ return;
+ }
+
if (!backend->priv->scheduled_populate_idle_id)
backend->priv->scheduled_populate_idle_id = g_idle_add_full (
G_PRIORITY_LOW,
@@ -654,7 +665,7 @@ collection_backend_notify_collection_cb (ESourceCollection *collection_extension
g_strcmp0 (g_param_spec_get_name (param), "mail-enabled") != 0))
return;
- collection_backend_schedule_populate_idle (collection_backend);
+ e_collection_backend_schedule_populate (collection_backend);
}
static void
@@ -724,6 +735,17 @@ collection_backend_auth_source_changed_cb (ESource *authentication_source,
}
}
+static void
+collection_backend_online_changed_cb (ECollectionBackend *collection_backend,
+ GParamSpec *param,
+ gpointer user_data)
+{
+ g_return_if_fail (E_IS_COLLECTION_BACKEND (collection_backend));
+
+ if (e_backend_get_online (E_BACKEND (collection_backend)))
+ collection_backend_schedule_populate_idle (collection_backend, FALSE);
+}
+
static void
collection_backend_set_server (ECollectionBackend *backend,
ESourceRegistryServer *server)
@@ -950,10 +972,10 @@ collection_backend_constructed (GObject *object)
/* Populate the newly-added collection from an idle callback
* so persistent child sources have a chance to be added first. */
- collection_backend_schedule_populate_idle (backend);
+ collection_backend_schedule_populate_idle (backend, TRUE);
backend->priv->notify_online_handler_id = g_signal_connect (backend, "notify::online",
- G_CALLBACK (e_collection_backend_schedule_populate), NULL);
+ G_CALLBACK (collection_backend_online_changed_cb), NULL);
}
static void
@@ -1982,5 +2004,5 @@ e_collection_backend_schedule_populate (ECollectionBackend *backend)
g_return_if_fail (E_IS_COLLECTION_BACKEND (backend));
if (e_backend_get_online (E_BACKEND (backend)))
- collection_backend_schedule_populate_idle (backend);
+ collection_backend_schedule_populate_idle (backend, TRUE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]