core: Threadsafe recursive direction creation is harder than it appears

This commit is contained in:
Colin Walters committed 2012-10-13 10:47:03 -04:00
1 parent b4d408f483
commit 6b09f90122
1 file changed
+17 -9
+17 -9
View File
@@ -57,19 +57,27 @@ ot_gfile_ensure_directory (GFile *dir,
gboolean ret = FALSE; gboolean ret = FALSE;
GError *temp_error = NULL; 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 (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 (parent)
ret = ot_gfile_ensure_directory (parent, TRUE, &temp_error); {
else if (!ot_gfile_ensure_directory (parent, TRUE, error))
ret = TRUE; goto out;
if (!g_file_make_directory (dir, NULL, error))
goto out;
} }
else else
ret = g_file_make_directory (dir, NULL, &temp_error); g_assert_not_reached ();
if (!ret) }
{ else if (!g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_EXISTS))
if (!g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_EXISTS))
{ {
g_propagate_error (error, temp_error); g_propagate_error (error, temp_error);
goto out; goto out;