[Xfce4-commits] <thunar:master> Only erase top-level items from trash (bug #7147).

Jannis Pohlmann noreply at xfce.org
Mon Jan 24 19:56:01 CET 2011


Updating branch refs/heads/master
         to bcdceffe0a292aa6ef24f149b746c9d5f15977be (commit)
       from c231b0f266ca52be057cac23dfef12d1c2995895 (commit)

commit bcdceffe0a292aa6ef24f149b746c9d5f15977be
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Mon Jan 24 19:52:39 2011 +0100

    Only erase top-level items from trash (bug #7147).
    
    Apparently, the GVfs trash backend only allows top-level directories in
    the trash to be modified. Children can be deleted implicitely but e.g.
    when emptying the trash, only the top-level items may be deleted.
    
    To give an example: g_file_delete() fails for "trash:///test/foo.txt"
    but succeeds for "trash:///test".
    
    This problem is covered in the trash specification under
    "Implementation notes".

 NEWS                              |    1 +
 thunar/thunar-io-jobs.c           |   11 ++++++-----
 thunar/thunar-io-scan-directory.c |   18 ++++++++++++++++--
 thunar/thunar-io-scan-directory.h |    3 ++-
 thunar/thunar-metafile.c          |    2 +-
 thunar/thunar-misc-jobs.c         |    4 ++--
 thunar/thunar-transfer-job.c      |    4 ++--
 7 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/NEWS b/NEWS
index 8928d29..b813f4e 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 1.3.x
 =====
 - Fix truncated strings when loading and storing emblems (bug #7171).
+- Only erase top-level items from trash (bug #7147).
 
 1.2.0
 =====
diff --git a/thunar/thunar-io-jobs.c b/thunar/thunar-io-jobs.c
index abb662a..898118a 100644
--- a/thunar/thunar-io-jobs.c
+++ b/thunar/thunar-io-jobs.c
@@ -39,6 +39,7 @@
 static GList *
 _tij_collect_nofollow (ThunarJob *job,
                        GList     *base_file_list,
+                       gboolean   unlinking,
                        GError   **error)
 {
   GError *err = NULL;
@@ -54,7 +55,7 @@ _tij_collect_nofollow (ThunarJob *job,
       /* try to scan the directory */
       child_file_list = thunar_io_scan_directory (job, lp->data, 
                                                   G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, 
-                                                  TRUE, &err);
+                                                  TRUE, unlinking, &err);
 
       /* prepend the new files to the existing list */
       file_list = thunar_g_file_list_prepend (file_list, lp->data);
@@ -386,7 +387,7 @@ _thunar_io_jobs_unlink (ThunarJob   *job,
   exo_job_info_message (EXO_JOB (job), _("Preparing..."));
 
   /* recursively collect files for removal, not following any symlinks */
-  file_list = _tij_collect_nofollow (job, file_list, &err);
+  file_list = _tij_collect_nofollow (job, file_list, TRUE, &err);
 
   /* free the file list and fail if there was an error or the job was cancelled */
   if (err != NULL || exo_job_is_cancelled (EXO_JOB (job)))
@@ -818,7 +819,7 @@ _thunar_io_jobs_chown (ThunarJob   *job,
 
   /* collect the files for the chown operation */
   if (recursive)
-    file_list = _tij_collect_nofollow (job, file_list, &err);
+    file_list = _tij_collect_nofollow (job, file_list, FALSE, &err);
   else
     file_list = thunar_g_file_list_copy (file_list);
 
@@ -965,7 +966,7 @@ _thunar_io_jobs_chmod (ThunarJob   *job,
 
   /* collect the files for the chown operation */
   if (recursive)
-    file_list = _tij_collect_nofollow (job, file_list, &err);
+    file_list = _tij_collect_nofollow (job, file_list, FALSE, &err);
   else
     file_list = thunar_g_file_list_copy (file_list);
 
@@ -1119,7 +1120,7 @@ _thunar_io_jobs_ls (ThunarJob   *job,
   /* collect directory contents (non-recursively) */
   path_list = thunar_io_scan_directory (job, directory, 
                                         G_FILE_QUERY_INFO_NONE, 
-                                        FALSE, &err);
+                                        FALSE, FALSE, &err);
 
   /* turn the GFile list into a ThunarFile list */
   for (lp = g_list_last (path_list); 
diff --git a/thunar/thunar-io-scan-directory.c b/thunar/thunar-io-scan-directory.c
index 7d0432f..6c38733 100644
--- a/thunar/thunar-io-scan-directory.c
+++ b/thunar/thunar-io-scan-directory.c
@@ -1,6 +1,6 @@
 /* vi:set et ai sw=2 sts=2 ts=2: */
 /*-
- * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
+ * Copyright (c) 2009-2011 Jannis Pohlmann <jannis at xfce.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -38,6 +38,7 @@ thunar_io_scan_directory (ThunarJob          *job,
                           GFile              *file,
                           GFileQueryInfoFlags flags,
                           gboolean            recursively,
+                          gboolean            unlinking,
                           GError            **error)
 {
   GFileEnumerator *enumerator;
@@ -56,6 +57,18 @@ thunar_io_scan_directory (ThunarJob          *job,
   if (exo_job_set_error_if_cancelled (EXO_JOB (job), error))
     return NULL;
 
+  /* don't recurse when we are scanning prior to unlinking and the current 
+   * file/dir is in the trash. In GVfs, only the top-level directories in 
+   * the trash can be modified and deleted directly. See
+   * http://bugzilla.xfce.org/show_bug.cgi?id=7147
+   * for more information */
+  if (unlinking
+      && thunar_g_file_is_trashed (file)
+      && !thunar_g_file_is_root (file))
+    {
+      return NULL;
+    }
+
   /* query the file type */
   type = g_file_query_file_type (file, flags, exo_job_get_cancellable (EXO_JOB (job)));
 
@@ -96,7 +109,8 @@ thunar_io_scan_directory (ThunarJob          *job,
       /* if the child is a directory and we need to recurse ... just do so */
       if (recursively && g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
         {
-          child_files = thunar_io_scan_directory (job, child_file, flags, recursively, &err);
+          child_files = thunar_io_scan_directory (job, child_file, flags, recursively, 
+                                                  unlinking, &err);
 
           /* prepend children to the file list to make sure they're 
            * processed first (required for unlinking) */
diff --git a/thunar/thunar-io-scan-directory.h b/thunar/thunar-io-scan-directory.h
index f654e68..1ace975 100644
--- a/thunar/thunar-io-scan-directory.h
+++ b/thunar/thunar-io-scan-directory.h
@@ -1,6 +1,6 @@
 /* vi:set et ai sw=2 sts=2 ts=2: */
 /*-
- * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
+ * Copyright (c) 2009-2011 Jannis Pohlmann <jannis at xfce.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -32,6 +32,7 @@ GList *thunar_io_scan_directory (ThunarJob          *job,
                                  GFile              *file,
                                  GFileQueryInfoFlags flags,
                                  gboolean            recursively,
+                                 gboolean            unlinking,
                                  GError            **error);
 
 G_END_DECLS
diff --git a/thunar/thunar-metafile.c b/thunar/thunar-metafile.c
index 4221296..03be917 100644
--- a/thunar/thunar-metafile.c
+++ b/thunar/thunar-metafile.c
@@ -1,7 +1,7 @@
 /* $Id$ */
 /*-
  * Copyright (c) 2005-2006 Benedikt Meurer <benny at xfce.org>
- * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
+ * Copyright (c) 2009-2011 Jannis Pohlmann <jannis at xfce.org>
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the Free
diff --git a/thunar/thunar-misc-jobs.c b/thunar/thunar-misc-jobs.c
index 9005cef..a541803 100644
--- a/thunar/thunar-misc-jobs.c
+++ b/thunar/thunar-misc-jobs.c
@@ -1,6 +1,6 @@
 /* vi:set et ai sw=2 sts=2 ts=2: */
 /*-
- * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
+ * Copyright (c) 2009-2011 Jannis Pohlmann <jannis at xfce.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -59,7 +59,7 @@ _thunar_misc_jobs_load_templates (ThunarJob   *job,
     {
       paths = thunar_io_scan_directory (job, templates_dir, 
                                         G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
-                                        TRUE, NULL);
+                                        TRUE, FALSE, NULL);
 
       /* turn the GFile list into a ThunarFile list */
       for (lp = g_list_last (paths); 
diff --git a/thunar/thunar-transfer-job.c b/thunar/thunar-transfer-job.c
index 8e3d0ea..364bd4e 100644
--- a/thunar/thunar-transfer-job.c
+++ b/thunar/thunar-transfer-job.c
@@ -1,7 +1,7 @@
 /* vi:set sw=2 sts=2 ts=2 et ai: */
 /*-
  * Copyright (c) 2005-2007 Benedikt Meurer <benny at xfce.org>
- * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
+ * Copyright (c) 2009-2011 Jannis Pohlmann <jannis at xfce.org>
  *
  * This program is free software; you can redistribute it and/or modify 
  * it under the terms of the GNU General Public License as published by 
@@ -195,7 +195,7 @@ thunar_transfer_job_collect_node (ThunarTransferJob  *job,
       /* scan the directory for immediate children */
       file_list = thunar_io_scan_directory (THUNAR_JOB (job), node->source_file,
                                             G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
-                                            FALSE, &err);
+                                            FALSE, FALSE, &err);
 
       /* add children to the transfer node */
       for (lp = file_list; err == NULL && lp != NULL; lp = lp->next)



More information about the Xfce4-commits mailing list