g_file_make_directory_with_parents: Fix error propagation

When creating a directory fails for some reason other than
the parent not existing, don't clear the error before we try
to propagate it.

To reproduce, run 'ostadmin init' on /ostree or otherwise try to
run the function on a directory with a parent directory where the
current user is not allowed to write.

https://bugzilla.gnome.org/show_bug.cgi?id=680823
This commit is contained in:
Owen W. Taylor 2012-07-30 13:33:05 +02:00
parent d7829ced53
commit b0bce4ad41

View File

@ -3395,12 +3395,14 @@ g_file_make_directory_with_parents (GFile *file,
work_file = g_object_ref (parent_file); work_file = g_object_ref (parent_file);
if (!result && my_error->code == G_IO_ERROR_NOT_FOUND) if (!result && my_error->code == G_IO_ERROR_NOT_FOUND)
list = g_list_prepend (list, parent_file); /* Transfer ownership of ref */ {
g_clear_error (&my_error);
list = g_list_prepend (list, parent_file); /* Transfer ownership of ref */
}
else else
g_object_unref (parent_file); g_object_unref (parent_file);
} }
g_clear_error (&my_error);
for (l = list; result && l; l = l->next) for (l = list; result && l; l = l->next)
{ {
result = g_file_make_directory ((GFile *) l->data, cancellable, &my_error); result = g_file_make_directory ((GFile *) l->data, cancellable, &my_error);