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




commit 4971cd5403b3b58444f2d4590b7b179d3335bb2d
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 | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/src/nautilus-tag-manager.c b/src/nautilus-tag-manager.c
index 5486c5cb7..327540074 100644
--- a/src/nautilus-tag-manager.c
+++ b/src/nautilus-tag-manager.c
@@ -224,7 +224,25 @@ get_query_status (TrackerSparqlCursor *cursor,
 GList *
 nautilus_tag_manager_get_starred_files (NautilusTagManager *self)
 {
-    return g_hash_table_get_keys (self->starred_file_uris);
+    GList *starred_file_uris;
+
+    starred_file_uris = g_hash_table_get_keys (self->starred_file_uris);
+
+    /* Filter out files ouside $HOME, because we don't support starring these
+     * yet. See comment on nautilus_tag_manager_can_star_contents() */
+    for (GList *l = starred_file_uris; l != NULL; l = l->next)
+    {
+        g_autoptr (GFile) file = g_file_new_for_uri (l->data);
+
+        if (!g_file_has_prefix (file, self->home))
+        {
+            GList *skip = l;
+            l = l->prev;
+            starred_file_uris = g_list_remove_link (starred_file_uris, skip);
+        }
+    }
+
+    return starred_file_uris;
 }
 
 static void


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