[dconf/wip/varlib: 10/12] engine: look for system-db in /var/lib
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf/wip/varlib: 10/12] engine: look for system-db in /var/lib
- Date: Fri, 6 Dec 2013 20:34:41 +0000 (UTC)
commit b2d93d4370a68fc65eb6892dfca040ff5569dc26
Author: Ryan Lortie <desrt desrt ca>
Date: Sun Dec 1 23:28:10 2013 -0500
engine: look for system-db in /var/lib
Move the expected location for system-db to /var/lib/dconf/db instead of
/etc/dconf/db. Add a fallback case to retain compatibility with system
that have the file in the old location, but print a warning.
Update the testcases to use the new location. A testcase will follow to
ensure that the fallback code is working properly.
engine/dconf-engine-source-system.c | 28 +++++++++++++++++++++++++++-
tests/engine.c | 20 ++++++++++----------
2 files changed, 37 insertions(+), 11 deletions(-)
---
diff --git a/engine/dconf-engine-source-system.c b/engine/dconf-engine-source-system.c
index 30e67eb..ea6800a 100644
--- a/engine/dconf-engine-source-system.c
+++ b/engine/dconf-engine-source-system.c
@@ -49,11 +49,37 @@ dconf_engine_source_system_reopen (DConfEngineSource *source)
GvdbTable *table;
gchar *filename;
- filename = g_build_filename ("/etc/dconf/db", source->name, NULL);
+ filename = g_build_filename ("/var/lib/dconf/db", source->name, NULL);
table = gvdb_table_new (filename, FALSE, &error);
if (table == NULL)
{
+ gchar *etc_filename;
+
+ /* This is just a fallback, so we want to keep the original error
+ * message in case of failure, as not to confuse anyone...
+ */
+ etc_filename = g_build_filename ("/etc/dconf/db", source->name, NULL);
+ table = gvdb_table_new (etc_filename, FALSE, NULL);
+
+ if (table != NULL)
+ {
+ if (!source->did_warn)
+ {
+ /* It wasn't in /var/lib, but opening the file in /etc worked... */
+ g_warning ("binary dconf database files in /etc/dconf/db are deprecated; please run
dconf-update");
+ source->did_warn = TRUE;
+ }
+
+ /* It worked, so clear the error. */
+ g_clear_error (&error);
+ }
+
+ g_free (etc_filename);
+ }
+
+ if (table == NULL)
+ {
if (!source->did_warn)
{
g_warning ("unable to open file '%s': %s; expect degraded performance", filename, error->message);
diff --git a/tests/engine.c b/tests/engine.c
index c523379..4a811ba 100644
--- a/tests/engine.c
+++ b/tests/engine.c
@@ -504,7 +504,7 @@ test_system_source (void)
/* Create the file after the fact and make sure it opens properly */
first_table = dconf_mock_gvdb_table_new ();
- dconf_mock_gvdb_install ("/etc/dconf/db/site", first_table);
+ dconf_mock_gvdb_install ("/var/lib/dconf/db/site", first_table);
reopened = dconf_engine_source_refresh (source);
g_assert (reopened);
@@ -517,7 +517,7 @@ test_system_source (void)
g_assert (source != NULL);
first_table = dconf_mock_gvdb_table_new ();
- dconf_mock_gvdb_install ("/etc/dconf/db/site", first_table);
+ dconf_mock_gvdb_install ("/var/lib/dconf/db/site", first_table);
/* Hang on to a copy for ourselves for below... */
dconf_mock_gvdb_table_ref (first_table);
@@ -533,7 +533,7 @@ test_system_source (void)
/* Replace the table on "disk" but don't invalidate the old one */
next_table = dconf_mock_gvdb_table_new ();
- dconf_mock_gvdb_install ("/etc/dconf/db/site", next_table);
+ dconf_mock_gvdb_install ("/var/lib/dconf/db/site", next_table);
/* Make sure the old table remains open (ie: no IO performed) */
reopened = dconf_engine_source_refresh (source);
@@ -548,7 +548,7 @@ test_system_source (void)
g_assert (source->values == next_table);
/* Remove the file entirely and do the same thing */
- dconf_mock_gvdb_install ("/etc/dconf/db/site", NULL);
+ dconf_mock_gvdb_install ("/var/lib/dconf/db/site", NULL);
reopened = dconf_engine_source_refresh (source);
g_assert (!reopened);
@@ -625,7 +625,7 @@ setup_state (guint n_sources,
state[i] = NULL;
}
- filename = g_strdup_printf ("/etc/dconf/db/db%d", i);
+ filename = g_strdup_printf ("/var/lib/dconf/db/db%d", i);
}
else
{
@@ -870,7 +870,7 @@ is_expected (const gchar *log_domain,
{
return g_str_equal (log_domain, "dconf") &&
log_level == (G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL) &&
- strstr (message, "unable to open file '/etc/dconf/db");
+ strstr (message, "unable to open file '/var/lib/dconf/db");
}
static gboolean
@@ -1097,7 +1097,7 @@ test_watch_fast (void)
table = dconf_mock_gvdb_table_new ();
dconf_mock_gvdb_install ("/HOME/.config/dconf/user", table);
table = dconf_mock_gvdb_table_new ();
- dconf_mock_gvdb_install ("/etc/dconf/db/site", table);
+ dconf_mock_gvdb_install ("/var/lib/dconf/db/site", table);
triv = g_variant_ref_sink (g_variant_new ("()"));
@@ -1146,7 +1146,7 @@ test_watch_fast (void)
dconf_mock_dbus_assert_no_async ();
dconf_mock_gvdb_install ("/HOME/.config/dconf/user", NULL);
- dconf_mock_gvdb_install ("/etc/dconf/db/site", NULL);
+ dconf_mock_gvdb_install ("/var/lib/dconf/db/site", NULL);
dconf_engine_unref (engine);
g_string_free (change_log, TRUE);
change_log = NULL;
@@ -1226,7 +1226,7 @@ test_change_fast (void)
locks = dconf_mock_gvdb_table_new ();
dconf_mock_gvdb_table_insert (locks, "/locked", g_variant_new_boolean (TRUE), NULL);
dconf_mock_gvdb_table_insert (table, ".locks", NULL, locks);
- dconf_mock_gvdb_install ("/etc/dconf/db/site", table);
+ dconf_mock_gvdb_install ("/var/lib/dconf/db/site", table);
empty = dconf_changeset_new ();
good_write = dconf_changeset_new_write ("/value", g_variant_new_string ("value"));
@@ -1404,7 +1404,7 @@ test_change_sync (void)
locks = dconf_mock_gvdb_table_new ();
dconf_mock_gvdb_table_insert (locks, "/locked", g_variant_new_boolean (TRUE), NULL);
dconf_mock_gvdb_table_insert (table, ".locks", NULL, locks);
- dconf_mock_gvdb_install ("/etc/dconf/db/site", table);
+ dconf_mock_gvdb_install ("/var/lib/dconf/db/site", table);
empty = dconf_changeset_new ();
good_write = dconf_changeset_new_write ("/value", g_variant_new_string ("value"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]