From a9c43f5a4e3d22f30c25c8fecfa587b2f54ee855 Mon Sep 17 00:00:00 2001 From: Yue-Lan Date: Wed, 19 Jul 2023 11:32:14 +0800 Subject: [PATCH] =?UTF-8?q?[FIX]=20#182831=20=E3=80=90=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=99=A8=E3=80=91=E5=88=A0=E9=99=A4=E4=BB=8E?= =?UTF-8?q?U=E7=9B=98=E6=8B=B7=E8=B4=9D=E5=88=B0=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E9=95=BF=E6=96=87=E4=BB=B6=E5=90=8D=E7=A7=B0=E7=9A=84=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=87=B3=E5=9B=9E=E6=94=B6=E7=AB=99=EF=BC=8C=E5=9B=9E?= =?UTF-8?q?=E6=94=B6=E7=AB=99=E4=B8=AD=E8=AF=A5=E6=96=87=E4=BB=B6=E4=B8=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=8E=9F=E5=A7=8B=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gio/glocalfile.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gio/glocalfile.c b/gio/glocalfile.c index 03c3aec..ce0e764 100644 --- a/gio/glocalfile.c +++ b/gio/glocalfile.c @@ -1985,6 +1985,8 @@ g_local_file_trash (GFile *file, GVfs *vfs; int errsv; gboolean is_local_file_in_usershare = FALSE; + GError *set_contents_error; + FILE *info_file; if (glib_should_use_portal ()) return g_trash_portal_trash_file (file, error); @@ -2276,9 +2278,24 @@ g_local_file_trash (GFile *file, original_name_escaped, delete_time); g_free (delete_time); + set_contents_error = NULL; g_file_set_contents_full (infofile, data, -1, G_FILE_SET_CONTENTS_CONSISTENT | G_FILE_SET_CONTENTS_ONLY_EXISTING, - 0600, NULL); + 0600, &set_contents_error); + if (set_contents_error) { +#ifdef G_OS_UNIX + if (g_error_matches (set_contents_error, G_FILE_ERROR, G_FILE_ERROR_NAMETOOLONG)) { + // direct write file + info_file = fopen (infofile, "w"); + if (info_file) { + fwrite (data, 1, strlen(data), info_file); + fflush (info_file); + fclose (info_file); + } + } +#endif + g_error_free (set_contents_error); + } /* TODO: Maybe we should verify that you can delete the file from the trash * before moving it? OTOH, that is hard, as it needs a recursive scan