From 67d42aba75af2bdeee4a50ca49a2a49aaa7a16ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Fernandes?= Date: Sat, 26 Sep 2020 19:16:51 +0100 Subject: 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..2362640fe 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_delete_link (starred_file_uris, skip); + } + } + + return starred_file_uris; } static void -- cgit v1.2.1