[dconf] engine: restructure a bit to improve testability
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf] engine: restructure a bit to improve testability
- Date: Mon, 25 Nov 2013 05:36:18 +0000 (UTC)
commit 1e0a743ab0ce1adb844c4540531d7794668ffd22
Author: Ryan Lortie <desrt desrt ca>
Date: Mon Nov 25 00:27:26 2013 -0500
engine: restructure a bit to improve testability
Don't use the access() system call from the service source because this
bypasses the mocking layer in the testsuite. Use gvdb_table_new()
instead. This also avoids an extra syscall.
Also: change a couple of criticals to warnings because they are not
programmer errors.
engine/dconf-engine-source-service.c | 27 ++++++++++++++++-----------
engine/dconf-engine-source-system.c | 2 +-
2 files changed, 17 insertions(+), 12 deletions(-)
---
diff --git a/engine/dconf-engine-source-service.c b/engine/dconf-engine-source-service.c
index 805a2d8..0bd0c05 100644
--- a/engine/dconf-engine-source-service.c
+++ b/engine/dconf-engine-source-service.c
@@ -55,22 +55,27 @@ dconf_engine_source_service_reopen (DConfEngineSource *source)
filename = g_build_filename (g_get_user_runtime_dir (), "dconf-service", source->name, NULL);
- /* If the file does not exist, kick the service to have it created. */
- if (access (filename, R_OK) != 0)
- dconf_engine_dbus_call_sync_func (source->bus_type, source->bus_name, source->object_path,
- "ca.desrt.dconf.Writer", "Init", NULL, NULL, NULL);
-
- table = gvdb_table_new (filename, FALSE, &error);
+ table = gvdb_table_new (filename, FALSE, NULL);
if (table == NULL)
{
- if (!did_warn)
+ /* If the file does not exist, kick the service to have it created. */
+ dconf_engine_dbus_call_sync_func (source->bus_type, source->bus_name, source->object_path,
+ "ca.desrt.dconf.Writer", "Init", g_variant_new ("()"), NULL, NULL);
+
+ /* try again */
+ table = gvdb_table_new (filename, FALSE, &error);
+
+ if (table == NULL)
{
- g_critical ("unable to open file '%s': %s; expect degraded performance", filename, error->message);
- did_warn = TRUE;
- }
+ if (!did_warn)
+ {
+ g_warning ("unable to open file '%s': %s; expect degraded performance", filename,
error->message);
+ did_warn = TRUE;
+ }
- g_error_free (error);
+ g_error_free (error);
+ }
}
g_free (filename);
diff --git a/engine/dconf-engine-source-system.c b/engine/dconf-engine-source-system.c
index 5e1317c..5d48e7f 100644
--- a/engine/dconf-engine-source-system.c
+++ b/engine/dconf-engine-source-system.c
@@ -57,7 +57,7 @@ dconf_engine_source_system_reopen (DConfEngineSource *source)
{
if (!did_warn)
{
- g_critical ("unable to open file '%s': %s; expect degraded performance", filename, error->message);
+ g_warning ("unable to open file '%s': %s; expect degraded performance", filename, error->message);
did_warn = TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]