From bd30a21a0ce1b40ca59814f731bd761670601aaa Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Wed, 2 Sep 2020 12:38:48 +0200 Subject: Limit starred files to within user's home directory Previously starred files were limited to directories indexed by Tracker. Since the 'Port to Tracker 3' commit this is no longer the case. However, to avoid unbounded growth in the starred files database we want to prevent starring of network locations and removable devices for now as these entries might go stale and we don't have any way to clean them up. --- src/nautilus-tag-manager.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/nautilus-tag-manager.c') diff --git a/src/nautilus-tag-manager.c b/src/nautilus-tag-manager.c index 2606d0d02..f41b3ec8f 100644 --- a/src/nautilus-tag-manager.c +++ b/src/nautilus-tag-manager.c @@ -41,6 +41,7 @@ struct _NautilusTagManager TrackerSparqlStatement *query_file_is_starred; GHashTable *starred_file_uris; + GFile *home; GCancellable *cancellable; }; @@ -676,4 +677,16 @@ nautilus_tag_manager_init (NautilusTagManager *self) (GDestroyNotify) g_free, /* values are keys */ NULL); + self->home = g_file_new_for_path (g_get_home_dir ()); +} + +gboolean +nautilus_tag_manager_can_star_contents (NautilusTagManager *tag_manager, + GFile *directory) +{ + /* We only allow files to be starred inside the home directory for now. + * This avoids the starred files database growing too big. + * See https://gitlab.gnome.org/GNOME/nautilus/-/merge_requests/553#note_903108 + */ + return g_file_has_prefix (directory, tag_manager->home) || g_file_equal (directory, tag_manager->home); } -- cgit v1.2.1