diff options
author | António Fernandes <antoniof@gnome.org> | 2020-09-26 19:16:51 +0100 |
---|---|---|
committer | António Fernandes <antoniof@gnome.org> | 2020-10-02 12:09:00 +0100 |
commit | 5a769fa1786aa5a8352405b61bccd7a63389d20e (patch) | |
tree | b4a763d1dc68dabc4aec3ee9c88f9f111ce217f2 | |
parent | 135190900b7f5b9bad0fc41a4aac8b88e0dd4c7f (diff) | |
download | nautilus-5a769fa1786aa5a8352405b61bccd7a63389d20e.tar.gz |
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.
-rw-r--r-- | src/nautilus-tag-manager.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/nautilus-tag-manager.c b/src/nautilus-tag-manager.c index 5486c5cb7..28b96c996 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 (starred_uri); + + /* 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 |