[FIX] #182831 【文件管理器】删除从U盘拷贝到本地长文件名称的文件至回收站,回收站中该文件不显示原始路径

This commit is contained in:
Yue-Lan 2023-07-19 11:32:14 +08:00
parent 0304b96160
commit a9c43f5a4e
1 changed files with 18 additions and 1 deletions

View File

@ -1985,6 +1985,8 @@ g_local_file_trash (GFile *file,
GVfs *vfs; GVfs *vfs;
int errsv; int errsv;
gboolean is_local_file_in_usershare = FALSE; gboolean is_local_file_in_usershare = FALSE;
GError *set_contents_error;
FILE *info_file;
if (glib_should_use_portal ()) if (glib_should_use_portal ())
return g_trash_portal_trash_file (file, error); return g_trash_portal_trash_file (file, error);
@ -2276,9 +2278,24 @@ g_local_file_trash (GFile *file,
original_name_escaped, delete_time); original_name_escaped, delete_time);
g_free (delete_time); g_free (delete_time);
set_contents_error = NULL;
g_file_set_contents_full (infofile, data, -1, 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, &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 /* 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