1 --- glib-2.82.0/gio/glocalfile.c.orig
2 +++ glib-2.82.0/gio/glocalfile.c
4 char *dirname, *globaldir;
10 GError *my_error = NULL;
11 @@ -2057,146 +2058,25 @@
15 - if (file_stat.st_dev == home_stat.st_dev)
16 + /* Always move to .Trash in the user's home directory */
17 + is_homedir_trash = TRUE;
19 + trashdir = g_build_filename (g_get_user_data_dir (), "Trash", NULL);
20 + if (g_mkdir_with_parents (trashdir, 0700) < 0)
22 - is_homedir_trash = TRUE;
24 - trashdir = g_build_filename (g_get_user_data_dir (), "Trash", NULL);
25 - if (g_mkdir_with_parents (trashdir, 0700) < 0)
30 - display_name = g_filename_display_name (trashdir);
31 - g_set_error (error, G_IO_ERROR,
32 - g_io_error_from_errno (errsv),
33 - _("Unable to create trash directory %s: %s"),
34 - display_name, g_strerror (errsv));
35 - g_free (display_name);
39 - topdir = g_strdup (g_get_user_data_dir ());
45 - gboolean success = FALSE;
48 - g_snprintf (uid_str, sizeof (uid_str), "%lu", (unsigned long)uid);
50 - topdir = _g_local_file_find_topdir_for (local->filename);
53 - g_set_io_error (error,
54 - _("Unable to find toplevel directory to trash %s"),
59 - if (ignore_trash_path (topdir))
61 - g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
62 - _("Trashing on system internal mounts is not supported"));
68 - /* Try looking for global trash dir $topdir/.Trash/$uid */
69 - globaldir = g_build_filename (topdir, ".Trash", NULL);
70 - if (g_lstat (globaldir, &global_stat) == 0 &&
71 - S_ISDIR (global_stat.st_mode) &&
72 - (global_stat.st_mode & S_ISVTX) != 0)
74 - trashdir = g_build_filename (globaldir, uid_str, NULL);
77 - if (g_lstat (trashdir, &trash_stat) == 0)
79 - if (!S_ISDIR (trash_stat.st_mode) ||
80 - trash_stat.st_uid != uid)
82 - /* Not a directory or not owned by user, ignore */
88 - else if (g_mkdir (trashdir, 0700) == -1)
97 - if (trashdir == NULL)
99 - gboolean tried_create;
101 - /* No global trash dir, or it failed the tests, fall back to $topdir/.Trash-$uid */
102 - dirname = g_strdup_printf (".Trash-%s", uid_str);
103 - trashdir = g_build_filename (topdir, dirname, NULL);
107 - tried_create = FALSE;
110 - if (g_lstat (trashdir, &trash_stat) == 0)
112 - if (!S_ISDIR (trash_stat.st_mode) ||
113 - trash_stat.st_uid != uid)
115 - /* Remove the failed directory */
117 - g_remove (trashdir);
119 - /* Not a directory or not owned by user, ignore */
125 - if (!tried_create &&
126 - g_mkdir (trashdir, 0700) != -1)
128 - /* Ensure that the created dir has the right uid etc.
129 - This might fail on e.g. a FAT dir */
130 - tried_create = TRUE;
142 - gchar *trashdir_display_name = NULL, *file_display_name = NULL;
144 - trashdir_display_name = g_filename_display_name (trashdir);
145 - file_display_name = g_filename_display_name (local->filename);
146 - g_set_error (error, G_IO_ERROR,
147 - G_IO_ERROR_NOT_SUPPORTED,
148 - _("Unable to find or create trash directory %s to trash %s"),
149 - trashdir_display_name, file_display_name);
151 - g_free (trashdir_display_name);
152 - g_free (file_display_name);
156 + char *display_name;
161 + display_name = g_filename_display_name (trashdir);
162 + g_set_error (error, G_IO_ERROR,
163 + g_io_error_from_errno (errsv),
164 + _("Unable to create trash directory %s: %s"),
165 + display_name, g_strerror (errsv));
166 + g_free (display_name);
170 + topdir = g_strdup (g_get_user_data_dir ());
172 /* Trashdir points to the trash dir with the "info" and "files" subdirectories */
174 @@ -2366,8 +2246,8 @@
175 trashfile = g_build_filename (filesdir, trashname, NULL);
179 - if (g_rename (local->filename, trashfile) == -1)
180 + trash = g_file_new_for_path(trashfile);
181 + if (!g_file_move (file, trash, 0, cancellable, NULL, NULL, NULL))
185 @@ -2376,6 +2256,7 @@
189 + g_object_unref(trash);
192 /* The trash dir was actually on another fs anyway!?
193 @@ -2398,6 +2279,7 @@
194 class->local_file_moved (vfs, local->filename, trashfile);
197 + g_object_unref(trash);
199 /* TODO: Do we need to update mtime/atime here after the move? */