diff options
author | Colin Walters <walters@verbum.org> | 2012-10-12 15:10:39 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2012-10-12 15:10:39 -0400 |
commit | 4436ed34d8da0f3caef0e6e41eebcb771b941096 (patch) | |
tree | e2c4d4db0e8c78fab815ef4a313f7b3713b6d6c4 | |
parent | 238da603b8646c7cca6e27fe901c8bb478fbd928 (diff) | |
download | ostree-4436ed34d8da0f3caef0e6e41eebcb771b941096.tar.gz |
core: Make mkdir -p function safer
Recursing here is just a more obvious way to do it, rather than
relying on the semantics of g_file_make_directory_with_parents().
-rw-r--r-- | src/libotutil/ot-gio-utils.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/libotutil/ot-gio-utils.c b/src/libotutil/ot-gio-utils.c index 31ea3fa8..1e985162 100644 --- a/src/libotutil/ot-gio-utils.c +++ b/src/libotutil/ot-gio-utils.c @@ -57,9 +57,11 @@ ot_gfile_ensure_directory (GFile *dir, gboolean ret = FALSE; GError *temp_error = NULL; - again: if (with_parents) - ret = g_file_make_directory_with_parents (dir, NULL, &temp_error); + { + ot_lobj GFile *parent = g_file_get_parent (dir); + ret = ot_gfile_ensure_directory (parent, TRUE, &temp_error); + } else ret = g_file_make_directory (dir, NULL, &temp_error); if (!ret) @@ -72,11 +74,6 @@ ot_gfile_ensure_directory (GFile *dir, else g_clear_error (&temp_error); } - /* Work around glib bug where if multiple threads/processes race in - * _with_parents, it can error out early - */ - if (with_parents && !g_file_query_exists (dir, NULL)) - goto again; ret = TRUE; out: |