Merge branch 'write_info_file_fail' into 'main'

GLocalFile: add error handle for trash info file writing

See merge request GNOME/glib!3170
This commit is contained in:
Philip Withnall 2022-12-29 12:33:55 +00:00
commit 46d3a016f3

View File

@ -2276,9 +2276,18 @@ g_local_file_trash (GFile *file,
original_name_escaped, delete_time); original_name_escaped, delete_time);
g_free (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, 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 /* 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 * before moving it? OTOH, that is hard, as it needs a recursive scan