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