gvfs/gvfs-bnc382172-home-trash-monitoring.patch

38 lines
1.2 KiB
Diff
Raw Normal View History

--- gvfs-0.2.3-post/daemon/gvfsbackendtrash.c 2008-04-07 20:27:43.000000000 -0500
+++ gvfs-0.2.3-work/daemon/gvfsbackendtrash.c 2008-05-13 00:04:28.000000000 -0500
@@ -517,12 +517,33 @@ list_trash_dirs (void)
GList *topdirs_info;
struct stat statbuf;
gboolean has_trash_files;
+ int stat_result;
dirs = NULL;
has_trash_files = FALSE;
home_trash = g_build_filename (g_get_user_data_dir (), "Trash", NULL);
- if (lstat (home_trash, &statbuf) == 0 &&
+
+ /* If the home trash directory doesn't exist at this point, we must create
+ * it in order to monitor it. */
+
+ stat_result = lstat (home_trash, &statbuf);
+
+ if (stat_result != 0)
+ {
+ gchar *home_trash_files = g_build_filename (home_trash, "files", NULL);
+ gchar *home_trash_info = g_build_filename (home_trash, "info", NULL);
+
+ g_mkdir_with_parents (home_trash_files, 0700);
+ g_mkdir_with_parents (home_trash_info, 0700);
+
+ g_free (home_trash_files);
+ g_free (home_trash_info);
+
+ stat_result = lstat (home_trash, &statbuf);
+ }
+
+ if (stat_result == 0 &&
S_ISDIR (statbuf.st_mode))
{
dirs = g_list_prepend (dirs, home_trash);