[evolution-data-server] EServerSideSource: Don't write changes to disk until exported.



commit af9783dc5c913ec73a5010a3a795b9bee0617b09
Author: Matthew Barnes <mbarnes redhat com>
Date:   Thu Jun 21 08:54:29 2012 -0400

    EServerSideSource: Don't write changes to disk until exported.
    
    If a collection backend is configuring an EServerSideSource from a
    worker thread, avoid writing changes to disk prematurely.
    
    Explicitly calling e_source_write_sync() still works as advertised
    whether the source is exported or not.

 libebackend/e-server-side-source.c     |    4 ++++
 libebackend/e-source-registry-server.c |    5 +++++
 2 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/libebackend/e-server-side-source.c b/libebackend/e-server-side-source.c
index 133ccad..048967c 100644
--- a/libebackend/e-server-side-source.c
+++ b/libebackend/e-server-side-source.c
@@ -508,6 +508,10 @@ server_side_source_changed (ESource *source)
 	gchar *new_data;
 	GError *error = NULL;
 
+	/* Do not write changes to disk until the source has been exported. */
+	if (!e_server_side_source_get_exported (E_SERVER_SIDE_SOURCE (source)))
+		return;
+
 	dbus_object = e_source_ref_dbus_object (source);
 	dbus_source = e_dbus_object_get_source (E_DBUS_OBJECT (dbus_object));
 
diff --git a/libebackend/e-source-registry-server.c b/libebackend/e-source-registry-server.c
index b06a1a6..542f288 100644
--- a/libebackend/e-source-registry-server.c
+++ b/libebackend/e-source-registry-server.c
@@ -1276,6 +1276,11 @@ e_source_registry_server_add_source (ESourceRegistryServer *server,
 
 	g_signal_emit (server, signals[SOURCE_ADDED], 0, source);
 
+	/* This is to ensure the source data gets written to disk, since
+	 * the ESource is exported now.  Could be racy otherwise if this
+	 * function is called from a worker thread. */
+	e_source_changed (source);
+
 	/* Adopt any orphans that have been waiting for this object. */
 	source_registry_server_adopt_orphans (server, source);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]