summaryrefslogtreecommitdiff
path: root/libebackend/e-source-registry-server.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2012-08-09 21:55:17 -0400
committerMatthew Barnes <mbarnes@redhat.com>2012-08-10 07:41:46 -0400
commit08459ae64e1809ff5c5e75436c94a50bb9185dea (patch)
treefb11bc7f6d1e3b5e00f0795044686f36eeab460a /libebackend/e-source-registry-server.c
parent1c1f1352917abe8b46088963952dc5d4a7d58020 (diff)
downloadevolution-data-server-08459ae64e1809ff5c5e75436c94a50bb9185dea.tar.gz
source_registry_server_create_source(): Create parent directories.
Same deal as the previous commit.
Diffstat (limited to 'libebackend/e-source-registry-server.c')
-rw-r--r--libebackend/e-source-registry-server.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/libebackend/e-source-registry-server.c b/libebackend/e-source-registry-server.c
index beca758e1..33a8afee2 100644
--- a/libebackend/e-source-registry-server.c
+++ b/libebackend/e-source-registry-server.c
@@ -702,9 +702,11 @@ source_registry_server_create_source (ESourceRegistryServer *server,
{
ESource *source = NULL;
GFile *file;
+ GFile *parent;
GKeyFile *key_file;
gboolean success;
gsize length;
+ GError *local_error = NULL;
g_return_val_if_fail (uid != NULL, FALSE);
g_return_val_if_fail (data != NULL, FALSE);
@@ -746,6 +748,20 @@ source_registry_server_create_source (ESourceRegistryServer *server,
file = e_server_side_source_new_user_file (uid);
+ /* Create the directory where we'll be writing. */
+
+ parent = g_file_get_parent (file);
+ g_file_make_directory_with_parents (parent, NULL, &local_error);
+ g_object_unref (parent);
+
+ if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_EXISTS))
+ g_clear_error (&local_error);
+
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
+ success = FALSE;
+ }
+
/* Write the data to disk. The file monitor should eventually
* notice the new file and call e_source_registry_server_load_file()
* per design, but we're going to beat it to the punch since we
@@ -754,9 +770,10 @@ source_registry_server_create_source (ESourceRegistryServer *server,
* it will simply get back the EDBusSourceObject we've already
* created and exported. */
- success = g_file_replace_contents (
- file, data, length, NULL, FALSE,
- G_FILE_CREATE_PRIVATE, NULL, NULL, error);
+ if (success)
+ success = g_file_replace_contents (
+ file, data, length, NULL, FALSE,
+ G_FILE_CREATE_PRIVATE, NULL, NULL, error);
if (success) {
ESourcePermissionFlags flags;