diff options
author | Ryan Lortie <desrt@desrt.ca> | 2013-11-25 00:27:26 -0500 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2013-11-25 00:34:44 -0500 |
commit | 1e0a743ab0ce1adb844c4540531d7794668ffd22 (patch) | |
tree | 2e19bfde32154170dcf02e197b90f22286824456 | |
parent | fa270c41e31f19b366beb03eaf340a38586144f9 (diff) | |
download | dconf-1e0a743ab0ce1adb844c4540531d7794668ffd22.tar.gz |
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.
-rw-r--r-- | engine/dconf-engine-source-service.c | 27 | ||||
-rw-r--r-- | 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; } |