summaryrefslogtreecommitdiff
path: root/gio
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2021-10-29 10:22:34 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2021-10-29 10:22:34 +0900
commit00a8f3da047be5a3af040c6cbf77258e3d561799 (patch)
tree2b8f96727dba9749e00356b24f2d2e17daa82f4f /gio
parentd9b5cb190cbe7b1d1486e0181e4d3b01e9552354 (diff)
downloadglib-00a8f3da047be5a3af040c6cbf77258e3d561799.tar.gz
glib-00a8f3da047be5a3af040c6cbf77258e3d561799.tar.bz2
glib-00a8f3da047be5a3af040c6cbf77258e3d561799.zip
Imported Upstream version 2.64.6upstream/2.64.6
Diffstat (limited to 'gio')
-rw-r--r--gio/goutputstream.c9
-rw-r--r--gio/gthreadedresolver.c2
-rw-r--r--gio/gtrashportal.c11
-rw-r--r--gio/tests/async-splice-output-stream.c27
-rw-r--r--gio/win32/gwinhttpfile.c24
5 files changed, 67 insertions, 6 deletions
diff --git a/gio/goutputstream.c b/gio/goutputstream.c
index 10f9aa732..dd6046dbe 100644
--- a/gio/goutputstream.c
+++ b/gio/goutputstream.c
@@ -2643,6 +2643,8 @@ g_output_stream_real_writev_finish (GOutputStream *stream,
typedef struct {
GInputStream *source;
GOutputStreamSpliceFlags flags;
+ guint istream_closed : 1;
+ guint ostream_closed : 1;
gssize n_read;
gssize n_written;
gsize bytes_copied;
@@ -2665,11 +2667,11 @@ real_splice_async_complete_cb (GTask *task)
SpliceData *op = g_task_get_task_data (task);
if (op->flags & G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE &&
- !g_input_stream_is_closed (op->source))
+ !op->istream_closed)
return;
if (op->flags & G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET &&
- !g_output_stream_is_closed (g_task_get_source_object (task)))
+ !op->ostream_closed)
return;
if (op->error != NULL)
@@ -2691,8 +2693,10 @@ real_splice_async_close_input_cb (GObject *source,
gpointer user_data)
{
GTask *task = user_data;
+ SpliceData *op = g_task_get_task_data (task);
g_input_stream_close_finish (G_INPUT_STREAM (source), res, NULL);
+ op->istream_closed = TRUE;
real_splice_async_complete_cb (task);
}
@@ -2707,6 +2711,7 @@ real_splice_async_close_output_cb (GObject *source,
GError **error = (op->error == NULL) ? &op->error : NULL;
g_output_stream_internal_close_finish (G_OUTPUT_STREAM (source), res, error);
+ op->ostream_closed = TRUE;
real_splice_async_complete_cb (task);
}
diff --git a/gio/gthreadedresolver.c b/gio/gthreadedresolver.c
index 7691b9124..8fb70366d 100644
--- a/gio/gthreadedresolver.c
+++ b/gio/gthreadedresolver.c
@@ -615,7 +615,7 @@ parse_res_txt (guchar *answer,
while (at < end)
{
len = *(at++);
- if (len > at - end)
+ if (len > (gsize) (end - at))
break;
g_ptr_array_add (array, g_strndup ((gchar *)at, len));
at += len;
diff --git a/gio/gtrashportal.c b/gio/gtrashportal.c
index 9922be21f..03c933297 100644
--- a/gio/gtrashportal.c
+++ b/gio/gtrashportal.c
@@ -74,8 +74,9 @@ g_trash_portal_trash_file (GFile *file,
GUnixFDList *fd_list = NULL;
int fd, fd_in, errsv;
gboolean ret = FALSE;
+ guint portal_result = 0;
GXdpTrash *proxy;
-
+
proxy = ensure_trash_portal ();
if (proxy == NULL)
{
@@ -114,11 +115,17 @@ g_trash_portal_trash_file (GFile *file,
ret = gxdp_trash_call_trash_file_sync (proxy,
g_variant_new_handle (fd_in),
fd_list,
- NULL,
+ &portal_result,
NULL,
NULL,
error);
+ if (ret && portal_result != 1)
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Trash portal failed on %s", path);
+ ret = FALSE;
+ }
+
out:
g_clear_object (&fd_list);
g_free (path);
diff --git a/gio/tests/async-splice-output-stream.c b/gio/tests/async-splice-output-stream.c
index e69c4db5d..fb317b733 100644
--- a/gio/tests/async-splice-output-stream.c
+++ b/gio/tests/async-splice-output-stream.c
@@ -32,6 +32,7 @@ typedef enum
TEST_THREADED_NONE = 0,
TEST_THREADED_ISTREAM = 1,
TEST_THREADED_OSTREAM = 2,
+ TEST_CANCEL = 4,
TEST_THREADED_BOTH = TEST_THREADED_ISTREAM | TEST_THREADED_OSTREAM,
} TestThreadedFlags;
@@ -58,6 +59,14 @@ test_copy_chunks_splice_cb (GObject *source,
bytes_spliced = g_output_stream_splice_finish (G_OUTPUT_STREAM (source),
res, &error);
+
+ if (data->flags & TEST_CANCEL)
+ {
+ g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
+ g_main_loop_quit (data->main_loop);
+ return;
+ }
+
g_assert_no_error (error);
g_assert_cmpint (bytes_spliced, ==, strlen (data->data));
@@ -100,11 +109,18 @@ test_copy_chunks_start (TestThreadedFlags flags)
{
TestCopyChunksData data;
GError *error = NULL;
+ GCancellable *cancellable = NULL;
data.main_loop = g_main_loop_new (NULL, FALSE);
data.data = "abcdefghijklmnopqrstuvwxyz";
data.flags = flags;
+ if (data.flags & TEST_CANCEL)
+ {
+ cancellable = g_cancellable_new ();
+ g_cancellable_cancel (cancellable);
+ }
+
if (data.flags & TEST_THREADED_ISTREAM)
{
GFile *file;
@@ -150,7 +166,7 @@ test_copy_chunks_start (TestThreadedFlags flags)
g_output_stream_splice_async (data.ostream, data.istream,
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE |
G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
- G_PRIORITY_DEFAULT, NULL,
+ G_PRIORITY_DEFAULT, cancellable,
test_copy_chunks_splice_cb, &data);
/* We do not hold a ref in data struct, this is to make sure the operation
@@ -158,6 +174,7 @@ test_copy_chunks_start (TestThreadedFlags flags)
*/
g_object_unref (data.istream);
g_object_unref (data.ostream);
+ g_clear_object (&cancellable);
g_main_loop_run (data.main_loop);
g_main_loop_unref (data.main_loop);
@@ -187,6 +204,12 @@ test_copy_chunks_threaded (void)
test_copy_chunks_start (TEST_THREADED_BOTH);
}
+static void
+test_cancelled (void)
+{
+ test_copy_chunks_start (TEST_THREADED_NONE | TEST_CANCEL);
+}
+
int
main (int argc,
char *argv[])
@@ -200,6 +223,8 @@ main (int argc,
test_copy_chunks_threaded_output);
g_test_add_func ("/async-splice/copy-chunks-threaded",
test_copy_chunks_threaded);
+ g_test_add_func ("/async-splice/cancelled",
+ test_cancelled);
return g_test_run();
}
diff --git a/gio/win32/gwinhttpfile.c b/gio/win32/gwinhttpfile.c
index cf5eed31d..509cdeb33 100644
--- a/gio/win32/gwinhttpfile.c
+++ b/gio/win32/gwinhttpfile.c
@@ -29,6 +29,7 @@
#include "gio/gfile.h"
#include "gio/gfileattribute.h"
#include "gio/gfileinfo.h"
+#include "gio/gfileinfo-priv.h"
#include "gwinhttpfile.h"
#include "gwinhttpfileinputstream.h"
#include "gwinhttpfileoutputstream.h"
@@ -178,6 +179,21 @@ g_winhttp_file_get_basename (GFile *file)
}
static char *
+g_winhttp_file_get_display_name (GFile *file)
+{
+ char *basename;
+
+ /* FIXME: This could be improved by using a new g_utf16_make_valid() function
+ * to recover what we can from the URI, and then suffixing it with
+ * “ (invalid encoding)” as per g_filename_display_basename(). */
+ basename = g_winhttp_file_get_basename (file);
+ if (!basename)
+ return g_strdup (_(" (invalid encoding)"));
+
+ return g_steal_pointer (&basename);
+}
+
+static char *
g_winhttp_file_get_path (GFile *file)
{
return NULL;
@@ -513,6 +529,14 @@ g_winhttp_file_query_info (GFile *file,
g_file_info_set_name (info, basename);
g_free (basename);
+ if (_g_file_attribute_matcher_matches_id (matcher,
+ G_FILE_ATTRIBUTE_ID_STANDARD_DISPLAY_NAME))
+ {
+ char *display_name = g_winhttp_file_get_display_name (file);
+ g_file_info_set_display_name (info, display_name);
+ g_free (display_name);
+ }
+
content_length = NULL;
if (_g_winhttp_query_header (winhttp_file->vfs,
request,