From 95c43129413f7b1a02599507c4799d9e414920d6 Mon Sep 17 00:00:00 2001 From: wangrong Date: Thu, 29 Dec 2022 12:33:55 +0000 Subject: [PATCH] GLocalFile: add error handle for trash info file writing --- gio/glocalfile.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gio/glocalfile.c b/gio/glocalfile.c index 4f8df369b..fe6c2ac0b 100644 --- a/gio/glocalfile.c +++ b/gio/glocalfile.c @@ -2278,9 +2278,18 @@ g_local_file_trash (GFile *file, original_name_escaped, delete_time); g_free (delete_time); - g_file_set_contents_full (infofile, data, -1, + if (!g_file_set_contents_full (infofile, data, -1, G_FILE_SET_CONTENTS_CONSISTENT | G_FILE_SET_CONTENTS_ONLY_EXISTING, - 0600, NULL); + 0600, error)) + { + g_unlink (infofile); + + g_free (filesdir); + g_free (trashname); + g_free (infofile); + + return FALSE; + } /* 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