mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-05-29 08:50:06 +02:00
GFile: fix the *_async_thread()
In the *_async_thread() functions, call the corresponding synchronous function instead of calling the interface vfunc, which can be NULL. In some cases the check for the vfunc == NULL was done, but to be consistent it is better to always call the synchronous version (and the code is simpler). https://bugzilla.gnome.org/show_bug.cgi?id=548353
This commit is contained in:
parent
1de0625103
commit
bd57c3f171
65
gio/gfile.c
65
gio/gfile.c
@ -5320,21 +5320,10 @@ open_read_async_thread (GTask *task,
|
|||||||
gpointer task_data,
|
gpointer task_data,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable)
|
||||||
{
|
{
|
||||||
GFileIface *iface;
|
|
||||||
GFileInputStream *stream;
|
GFileInputStream *stream;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
iface = G_FILE_GET_IFACE (object);
|
stream = g_file_read (G_FILE (object), cancellable, &error);
|
||||||
|
|
||||||
if (iface->read_fn == NULL)
|
|
||||||
{
|
|
||||||
g_task_return_new_error (task, G_IO_ERROR,
|
|
||||||
G_IO_ERROR_NOT_SUPPORTED,
|
|
||||||
_("Operation not supported"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
stream = iface->read_fn (G_FILE (object), cancellable, &error);
|
|
||||||
if (stream)
|
if (stream)
|
||||||
g_task_return_pointer (task, stream, g_object_unref);
|
g_task_return_pointer (task, stream, g_object_unref);
|
||||||
else
|
else
|
||||||
@ -5372,14 +5361,11 @@ append_to_async_thread (GTask *task,
|
|||||||
gpointer task_data,
|
gpointer task_data,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable)
|
||||||
{
|
{
|
||||||
GFileIface *iface;
|
|
||||||
GFileCreateFlags *data = task_data;
|
GFileCreateFlags *data = task_data;
|
||||||
GFileOutputStream *stream;
|
GFileOutputStream *stream;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
iface = G_FILE_GET_IFACE (source_object);
|
stream = g_file_append_to (G_FILE (source_object), *data, cancellable, &error);
|
||||||
|
|
||||||
stream = iface->append_to (G_FILE (source_object), *data, cancellable, &error);
|
|
||||||
if (stream)
|
if (stream)
|
||||||
g_task_return_pointer (task, stream, g_object_unref);
|
g_task_return_pointer (task, stream, g_object_unref);
|
||||||
else
|
else
|
||||||
@ -5424,14 +5410,11 @@ create_async_thread (GTask *task,
|
|||||||
gpointer task_data,
|
gpointer task_data,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable)
|
||||||
{
|
{
|
||||||
GFileIface *iface;
|
|
||||||
GFileCreateFlags *data = task_data;
|
GFileCreateFlags *data = task_data;
|
||||||
GFileOutputStream *stream;
|
GFileOutputStream *stream;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
iface = G_FILE_GET_IFACE (source_object);
|
stream = g_file_create (G_FILE (source_object), *data, cancellable, &error);
|
||||||
|
|
||||||
stream = iface->create (G_FILE (source_object), *data, cancellable, &error);
|
|
||||||
if (stream)
|
if (stream)
|
||||||
g_task_return_pointer (task, stream, g_object_unref);
|
g_task_return_pointer (task, stream, g_object_unref);
|
||||||
else
|
else
|
||||||
@ -5492,14 +5475,11 @@ replace_async_thread (GTask *task,
|
|||||||
gpointer task_data,
|
gpointer task_data,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable)
|
||||||
{
|
{
|
||||||
GFileIface *iface;
|
|
||||||
GFileOutputStream *stream;
|
GFileOutputStream *stream;
|
||||||
ReplaceAsyncData *data = task_data;
|
ReplaceAsyncData *data = task_data;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
iface = G_FILE_GET_IFACE (source_object);
|
stream = g_file_replace (G_FILE (source_object),
|
||||||
|
|
||||||
stream = iface->replace (G_FILE (source_object),
|
|
||||||
data->etag,
|
data->etag,
|
||||||
data->make_backup,
|
data->make_backup,
|
||||||
data->flags,
|
data->flags,
|
||||||
@ -5554,15 +5534,9 @@ delete_async_thread (GTask *task,
|
|||||||
gpointer task_data,
|
gpointer task_data,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable)
|
||||||
{
|
{
|
||||||
GFile *file = object;
|
|
||||||
GFileIface *iface;
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
iface = G_FILE_GET_IFACE (object);
|
if (g_file_delete (G_FILE (object), cancellable, &error))
|
||||||
|
|
||||||
if (iface->delete_file (file,
|
|
||||||
cancellable,
|
|
||||||
&error))
|
|
||||||
g_task_return_boolean (task, TRUE);
|
g_task_return_boolean (task, TRUE);
|
||||||
else
|
else
|
||||||
g_task_return_error (task, error);
|
g_task_return_error (task, error);
|
||||||
@ -5638,20 +5612,10 @@ open_readwrite_async_thread (GTask *task,
|
|||||||
gpointer task_data,
|
gpointer task_data,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable)
|
||||||
{
|
{
|
||||||
GFileIface *iface;
|
|
||||||
GFileIOStream *stream;
|
GFileIOStream *stream;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
iface = G_FILE_GET_IFACE (object);
|
stream = g_file_open_readwrite (G_FILE (object), cancellable, &error);
|
||||||
|
|
||||||
if (iface->open_readwrite == NULL)
|
|
||||||
{
|
|
||||||
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
|
||||||
_("Operation not supported"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
stream = iface->open_readwrite (G_FILE (object), cancellable, &error);
|
|
||||||
|
|
||||||
if (stream == NULL)
|
if (stream == NULL)
|
||||||
g_task_return_error (task, error);
|
g_task_return_error (task, error);
|
||||||
@ -5691,21 +5655,11 @@ create_readwrite_async_thread (GTask *task,
|
|||||||
gpointer task_data,
|
gpointer task_data,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable)
|
||||||
{
|
{
|
||||||
GFileIface *iface;
|
|
||||||
GFileCreateFlags *data = task_data;
|
GFileCreateFlags *data = task_data;
|
||||||
GFileIOStream *stream;
|
GFileIOStream *stream;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
iface = G_FILE_GET_IFACE (object);
|
stream = g_file_create_readwrite (G_FILE (object), *data, cancellable, &error);
|
||||||
|
|
||||||
if (iface->create_readwrite == NULL)
|
|
||||||
{
|
|
||||||
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
|
||||||
_("Operation not supported"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
stream = iface->create_readwrite (G_FILE (object), *data, cancellable, &error);
|
|
||||||
|
|
||||||
if (stream == NULL)
|
if (stream == NULL)
|
||||||
g_task_return_error (task, error);
|
g_task_return_error (task, error);
|
||||||
@ -5764,14 +5718,11 @@ replace_readwrite_async_thread (GTask *task,
|
|||||||
gpointer task_data,
|
gpointer task_data,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable)
|
||||||
{
|
{
|
||||||
GFileIface *iface;
|
|
||||||
GFileIOStream *stream;
|
GFileIOStream *stream;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
ReplaceRWAsyncData *data = task_data;
|
ReplaceRWAsyncData *data = task_data;
|
||||||
|
|
||||||
iface = G_FILE_GET_IFACE (object);
|
stream = g_file_replace_readwrite (G_FILE (object),
|
||||||
|
|
||||||
stream = iface->replace_readwrite (G_FILE (object),
|
|
||||||
data->etag,
|
data->etag,
|
||||||
data->make_backup,
|
data->make_backup,
|
||||||
data->flags,
|
data->flags,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user