[gvfs] google: Fix issue with stale entries remaining after rename operation



commit 95511d5dbf15952aa4d9d05041997f5e100e576a
Author: Mayank Sharma <mayank8019 gmail com>
Date:   Thu Jul 18 01:18:43 2019 +0530

    google: Fix issue with stale entries remaining after rename operation
    
    Currently, whenever we perform a rename operation, we set the `entry`'s
    title to new display name, but at the time of removal of this entry from
    cache, we still use the newer title. Hence, each time rename is done, a
    single stale entry remains. This commit fixes the issue by reverting
    back the title to the original display name of `entry` and then
    performing a removal from cache.
    
    Fixes: https://gitlab.gnome.org/GNOME/gvfs/issues/410

 daemon/gvfsbackendgoogle.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/daemon/gvfsbackendgoogle.c b/daemon/gvfsbackendgoogle.c
index 55c206d1..652b230f 100644
--- a/daemon/gvfsbackendgoogle.c
+++ b/daemon/gvfsbackendgoogle.c
@@ -2410,6 +2410,11 @@ g_vfs_backend_google_set_display_name (GVfsBackend           *_self,
       goto out;
     }
 
+  /* The internal ref count has to be increased before removing the entry since
+   * remove_entry_full calls g_object_unref(). */
+  g_object_ref (entry);
+  remove_entry (self, entry);
+
   gdata_entry_set_title (entry, display_name);
   auth_domain = gdata_documents_service_get_primary_authorization_domain ();
 
@@ -2420,14 +2425,15 @@ g_vfs_backend_google_set_display_name (GVfsBackend           *_self,
       sanitize_error (&error);
       g_vfs_job_failed_from_error (G_VFS_JOB (job), error);
       g_error_free (error);
+      g_object_unref (entry);
       goto out;
     }
 
-  remove_entry (self, entry);
   insert_entry (self, new_entry);
   g_hash_table_foreach (self->monitors, emit_attribute_changed_event, entry_path);
   g_vfs_job_set_display_name_set_new_path (job, entry_path);
   g_vfs_job_succeeded (G_VFS_JOB (job));
+  g_object_unref (entry);
 
  out:
   g_clear_object (&new_entry);


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