[gvfs] MTP: When removing cache entries, remove children too.



commit cc83b6b557bb2c23833242f308dd5b4478b8bd30
Author: Philip Langdale <philipl overt org>
Date:   Tue Feb 26 08:16:15 2013 -0800

    MTP: When removing cache entries, remove children too.
    
    If a directory is deleted or renamed, everything inside it has to
    be invalidated in the cache too. The simplest way to do this is
    to remove by string prefix match. This will remove too many entries
    if there are filenames that match the prefix but aren't actually
    children. This is ok as the cache will be repopulated as needed
    and operations that invalidate the cache are infrequent.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=696016

 daemon/gvfsbackendmtp.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/daemon/gvfsbackendmtp.c b/daemon/gvfsbackendmtp.c
index 9e4f3f1..0841a5c 100644
--- a/daemon/gvfsbackendmtp.c
+++ b/daemon/gvfsbackendmtp.c
@@ -264,12 +264,27 @@ static CacheEntry *get_cache_entry (GVfsBackendMtp *backend,
 }
 
 
+static gboolean
+remove_cache_entry_by_prefix (gpointer key,
+                              gpointer value,
+                              gpointer user_data)
+{
+  const char *path = key;
+  const char *prefix = user_data;
+
+  return g_str_has_prefix (path, prefix);
+}
+
+
 static void
 remove_cache_entry (GVfsBackendMtp *backend,
                     const char *path)
 {
   DEBUG ("(III) remove_cache_entry: %s", path);
-  g_hash_table_remove (backend->file_cache, path);
+  //g_hash_table_remove (backend->file_cache, path);
+  g_hash_table_foreach_remove (backend->file_cache,
+                               remove_cache_entry_by_prefix,
+                               (gpointer) path);
   DEBUG ("(III) remove_cache_entry done");
 }
 


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