[ostree] core: Threadsafe recursive direction creation is harder than it appears
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] core: Threadsafe recursive direction creation is harder than it appears
- Date: Sat, 13 Oct 2012 14:49:36 +0000 (UTC)
commit 6b09f90122a999569d9c2581568c27bb3a8a8a75
Author: Colin Walters <walters verbum org>
Date: Fri Oct 12 17:44:02 2012 -0400
core: Threadsafe recursive direction creation is harder than it appears
src/libotutil/ot-gio-utils.c | 32 ++++++++++++++++++++------------
1 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/src/libotutil/ot-gio-utils.c b/src/libotutil/ot-gio-utils.c
index bf3743d..e06eebe 100644
--- a/src/libotutil/ot-gio-utils.c
+++ b/src/libotutil/ot-gio-utils.c
@@ -57,19 +57,27 @@ ot_gfile_ensure_directory (GFile *dir,
gboolean ret = FALSE;
GError *temp_error = NULL;
- if (with_parents)
+ if (!g_file_make_directory (dir, NULL, &temp_error))
{
- ot_lobj GFile *parent = g_file_get_parent (dir);
- if (parent)
- ret = ot_gfile_ensure_directory (parent, TRUE, &temp_error);
- else
- ret = TRUE;
- }
- else
- ret = g_file_make_directory (dir, NULL, &temp_error);
- if (!ret)
- {
- if (!g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_EXISTS))
+ if (with_parents &&
+ g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
+ {
+ ot_lobj GFile *parent = NULL;
+
+ g_clear_error (&temp_error);
+
+ parent = g_file_get_parent (dir);
+ if (parent)
+ {
+ if (!ot_gfile_ensure_directory (parent, TRUE, error))
+ goto out;
+ if (!g_file_make_directory (dir, NULL, error))
+ goto out;
+ }
+ else
+ g_assert_not_reached ();
+ }
+ else if (!g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_EXISTS))
{
g_propagate_error (error, temp_error);
goto out;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]