mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
Merge branch 'wip/oholy/trash-recursion' into 'master'
gio-tool-trash: Prevent recursion to speed up emptying trash See merge request GNOME/glib!1654
This commit is contained in:
commit
f2df054673
@ -40,6 +40,8 @@ delete_trash_file (GFile *file, gboolean del_file, gboolean del_children)
|
||||
GFile *child;
|
||||
GFileEnumerator *enumerator;
|
||||
|
||||
g_return_if_fail (g_file_has_uri_scheme (file, "trash"));
|
||||
|
||||
if (del_children)
|
||||
{
|
||||
enumerator = g_file_enumerate_children (file,
|
||||
@ -53,7 +55,14 @@ delete_trash_file (GFile *file, gboolean del_file, gboolean del_children)
|
||||
while ((info = g_file_enumerator_next_file (enumerator, NULL, NULL)) != NULL)
|
||||
{
|
||||
child = g_file_get_child (file, g_file_info_get_name (info));
|
||||
delete_trash_file (child, TRUE, g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY);
|
||||
|
||||
/* The g_file_delete operation works differently for locations
|
||||
* provided by the trash backend as it prevents modifications of
|
||||
* trashed items. For that reason, it is enough to call
|
||||
* g_file_delete on top-level items only.
|
||||
*/
|
||||
delete_trash_file (child, TRUE, FALSE);
|
||||
|
||||
g_object_unref (child);
|
||||
g_object_unref (info);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user