mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 14:36:13 +01:00
gio: Check cancellable iterating local file enumerator
In the typical `while (g_file_enumerator_next_file ())` patterns, there is nothing much checking whether the operation was cancelled on the GIO side. Unless the user checks for the case, this means local enumerators always run to completion even if cancelled. Fix this by checking the cancellable state explicitly for local enumerators, so there are oportunities for bailing out early if the enumerator is going through a very large directory.
This commit is contained in:
parent
eaaa2b5f66
commit
99571c42d5
@ -23,6 +23,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <gcancellable.h>
|
||||
#include <glocalfileenumerator.h>
|
||||
#include <glocalfileinfo.h>
|
||||
#include <glocalfile.h>
|
||||
@ -383,6 +384,9 @@ g_local_file_enumerator_next_file (GFileEnumerator *enumerator,
|
||||
|
||||
next_file:
|
||||
|
||||
if (g_cancellable_set_error_if_cancelled (cancellable, error))
|
||||
return NULL;
|
||||
|
||||
#ifdef USE_GDIR
|
||||
filename = g_dir_read_name (local->dir);
|
||||
file_type = G_FILE_TYPE_UNKNOWN;
|
||||
|
Loading…
Reference in New Issue
Block a user