[gvfs] trash: Rescan trash dirs before operations with files



commit 7d0ef03610164e80d15897134d82a8e82bd006a3
Author: Ondrej Holy <oholy redhat com>
Date:   Tue Mar 15 10:35:21 2016 +0100

    trash: Rescan trash dirs before operations with files
    
    Patches to use G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT were recently proposed
    for Nautilus and GTK+. We have to be sure that the item count is valid
    and therefore we have to rescan the trash dirs before. Otherwise the
    count is 0 if enumeration isn't called before, which is obviously wrong.
    Similarly, trash dirs have to be rescanned before other operations
    (i.e. read, delete, pull), otherwise the operations may fail with
    G_IO_ERROR_NOT_FOUND if enumeration wasn't called before.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=711459

 daemon/gvfsbackendtrash.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/daemon/gvfsbackendtrash.c b/daemon/gvfsbackendtrash.c
index 8cddeae..f90d69b 100644
--- a/daemon/gvfsbackendtrash.c
+++ b/daemon/gvfsbackendtrash.c
@@ -237,6 +237,9 @@ trash_backend_open_for_read (GVfsBackend        *vfs_backend,
     {
       GFile *real;
 
+      if (!backend->file_monitor && !backend->dir_monitor)
+        trash_watcher_rescan (backend->watcher);
+
       real = trash_backend_get_file (backend, filename, NULL, NULL, &error);
 
       if (real)
@@ -403,6 +406,9 @@ trash_backend_delete (GVfsBackend   *vfs_backend,
       TrashItem *item;
       GFile *real;
 
+      if (!backend->file_monitor && !backend->dir_monitor)
+        trash_watcher_rescan (backend->watcher);
+
       real = trash_backend_get_file (backend, filename,
                                      &item, &is_toplevel, &error);
 
@@ -459,6 +465,9 @@ trash_backend_pull (GVfsBackend           *vfs_backend,
       TrashItem *item;
       GFile *real;
 
+      if (!backend->file_monitor && !backend->dir_monitor)
+        trash_watcher_rescan (backend->watcher);
+
       real = trash_backend_get_file (backend, source, &item,
                                      &is_toplevel, &error);
 
@@ -717,6 +726,9 @@ trash_backend_query_info (GVfsBackend           *vfs_backend,
 
   g_assert (filename[0] == '/');
 
+  if (!backend->file_monitor && !backend->dir_monitor)
+    trash_watcher_rescan (backend->watcher);
+
   if (filename[1])
     {
       GError *error = NULL;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]