[dconf] service: try mkdir_with_parents() on failed writes
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf] service: try mkdir_with_parents() on failed writes
- Date: Wed, 2 Jan 2013 19:23:13 +0000 (UTC)
commit a2bad17d26b596ef46fd2e9c60b9e0163a51012d
Author: Ryan Lortie <desrt desrt ca>
Date: Wed Jan 2 14:20:10 2013 -0500
service: try mkdir_with_parents() on failed writes
If we fail to write the database file, try g_mkdir_with_parents() to
create the parent directory and try again.
https://bugzilla.gnome.org/show_bug.cgi?id=689136
service/dconf-gvdb-utils.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/service/dconf-gvdb-utils.c b/service/dconf-gvdb-utils.c
index 9e0c4b1..a9b7ab4 100644
--- a/service/dconf-gvdb-utils.c
+++ b/service/dconf-gvdb-utils.c
@@ -160,6 +160,22 @@ dconf_gvdb_utils_write_file (const gchar *filename,
gvdb = gvdb_hash_table_new (NULL, NULL);
dconf_changeset_all (database, dconf_gvdb_utils_add_key, gvdb);
success = gvdb_table_write_contents (gvdb, filename, FALSE, error);
+
+ if (!success)
+ {
+ gchar *dirname;
+
+ /* Maybe it failed because the directory doesn't exist. Try
+ * again, after mkdir().
+ */
+ dirname = g_path_get_dirname (filename);
+ g_mkdir_with_parents (dirname, 0777);
+ g_free (dirname);
+
+ g_clear_error (error);
+ success = gvdb_table_write_contents (gvdb, filename, FALSE, error);
+ }
+
g_hash_table_unref (gvdb);
return success;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]