[nautilus/wip/antoniof/update-starred-uris] tag-manager: Ignore starred files ouside $HOME




commit b4b807018fc06380fbe02cb51f16703a446e4ff6
Author: António Fernandes <antoniof gnome org>
Date:   Sat Sep 26 19:16:51 2020 +0100

    tag-manager: Ignore starred files ouside $HOME
    
    At the moment we restrict starring to within Home, but the database
    might include URIs from outside of it. Such may happen after a file
    move operation, as per the previous commit.
    
    Keeping the moved URIs in the database is useful in case the move is
    undone, because we change the URI back. But otherwise, the non-home
    URIs remain in the database indefinitely.
    
    So, let's filter them out when listing the starred files.

 src/nautilus-tag-manager.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
---
diff --git a/src/nautilus-tag-manager.c b/src/nautilus-tag-manager.c
index 5486c5cb7..58b48ca17 100644
--- a/src/nautilus-tag-manager.c
+++ b/src/nautilus-tag-manager.c
@@ -224,7 +224,24 @@ get_query_status (TrackerSparqlCursor *cursor,
 GList *
 nautilus_tag_manager_get_starred_files (NautilusTagManager *self)
 {
-    return g_hash_table_get_keys (self->starred_file_uris);
+    GHashTableIter starred_iter;
+    gchar *starred_uri;
+    GList *starred_file_uris = NULL;
+
+    g_hash_table_iter_init (&starred_iter, self->starred_file_uris);
+    while (g_hash_table_iter_next (&starred_iter, (gpointer *) &starred_uri, NULL))
+    {
+        g_autoptr (GFile) file = g_file_new_for_uri (l->data);
+
+        /* Skip files ouside $HOME, because we don't support starring these yet.
+         * See comment on nautilus_tag_manager_can_star_contents() */
+        if (g_file_has_prefix (file, self->home))
+        {
+            starred_file_uris = g_list_prepend (starred_file_uris, starred_uri);
+        }
+    }
+
+    return starred_file_uris;
 }
 
 static void


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