diff options
author | Sam Thursfield <sam@afuera.me.uk> | 2020-05-02 16:46:28 +0200 |
---|---|---|
committer | Sam Thursfield <sam@afuera.me.uk> | 2020-09-02 17:28:38 +0200 |
commit | 7712c2c7e10b3c28b2cc2ec8dfeeb8a89bd57945 (patch) | |
tree | 750ca0505da110cc1d9d9cb166cccf0eeacc8aa7 /src/nautilus-search-engine-tracker.c | |
parent | ae2669dcf8695260c7f3385bec836b92bcb57f5c (diff) | |
download | nautilus-7712c2c7e10b3c28b2cc2ec8dfeeb8a89bd57945.tar.gz |
Port to Tracker 3
Mostly the port is straightforward, we connect to tracker-miner-fs
explicitly over D-Bus instead of the centralized tracker-store daemon
we connected to previously.
The search-engine-tracker test is now isolated from the user's real
Tracker index using the `tracker-sandbox` script provided by Tracker,
and it lets tracker-miner-fs index the test file rather than trying
to synthesize the expected database contents.
There are more changes in nautilus-tag-manager.c. Until now, starred
file information was stored in the tracker-miner-fs database. This has
some downsides, firstly the data is deleted if someone runs `tracker
reset --hard`, secondly it isn't possible to do this from inside a
Flatpak sandbox with Tracker 3.0. because the
This commit changes the NautilusTagManager to set up a private
database inside XDG_DATA_HOME/nautilus/tags. This stores the starred
file information. The database is managed with Tracker, which allows us
to continue using the rename-tracking that tracker-miner-fs provides.
The same limitations apply as before that only files in indexed
locations can be starred.
Diffstat (limited to 'src/nautilus-search-engine-tracker.c')
-rw-r--r-- | src/nautilus-search-engine-tracker.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/nautilus-search-engine-tracker.c b/src/nautilus-search-engine-tracker.c index cff28eb71..44f4a9cf6 100644 --- a/src/nautilus-search-engine-tracker.c +++ b/src/nautilus-search-engine-tracker.c @@ -55,6 +55,8 @@ enum LAST_PROP }; +#define TRACKER_MINER_FS_BUSNAME "org.freedesktop.Tracker3.Miner.Files" + static void nautilus_search_provider_init (NautilusSearchProviderInterface *iface); G_DEFINE_TYPE_WITH_CODE (NautilusSearchEngineTracker, @@ -334,43 +336,53 @@ nautilus_search_engine_tracker_start (NautilusSearchProvider *provider) mimetypes = nautilus_query_get_mime_types (tracker->query); sparql = g_string_new ("SELECT DISTINCT" - " nie:url(?urn)" + " ?url" " xsd:double(COALESCE(?rank2, ?rank1)) AS ?rank" - " nfo:fileLastModified(?urn)" - " nfo:fileLastAccessed(?urn)"); + " nfo:fileLastModified(?file)" + " nfo:fileLastAccessed(?file)"); + + if (tracker->fts_enabled && *search_text) + { + g_string_append (sparql, " fts:snippet(?content)"); + } + + g_string_append (sparql, "FROM tracker:FileSystem "); if (tracker->fts_enabled) { - g_string_append (sparql, " fts:snippet(?urn)"); + g_string_append (sparql, "FROM tracker:Documents "); } g_string_append (sparql, "\nWHERE {" - " ?urn a nfo:FileDataObject;" + " ?file a nfo:FileDataObject;" " nfo:fileLastModified ?mtime;" " nfo:fileLastAccessed ?atime;" - " tracker:available true;" - " nie:url ?url"); + " nie:dataSource/tracker:available true;" + " nie:url ?url."); if (mimetypes->len > 0) { - g_string_append (sparql, "; nie:mimeType ?mime"); + g_string_append (sparql, + " ?content nie:isStoredAs ?file;" + " nie:mimeType ?mime"); } if (tracker->fts_enabled) { /* Use fts:match only for content search to not lose some filename results due to stop words. */ g_string_append_printf (sparql, - " {" - " ?urn fts:match '\"nie:plainTextContent\" : \"%s\"*' ." - " BIND(fts:rank(?urn) AS ?rank1) ." + " { " + " ?content nie:isStoredAs ?file ." + " ?content fts:match \"%s*\" ." + " BIND(fts:rank(?content) AS ?rank1) ." " } UNION", search_text); } g_string_append_printf (sparql, " {" - " ?urn nfo:fileName ?filename ." + " ?file nfo:fileName ?filename ." " FILTER(fn:contains(fn:lower-case(?filename), '%s')) ." " BIND(" FILENAME_RANK " AS ?rank2) ." " }", @@ -561,7 +573,7 @@ nautilus_search_engine_tracker_init (NautilusSearchEngineTracker *engine) engine->hits_pending = g_queue_new (); - engine->connection = tracker_sparql_connection_get (NULL, &error); + engine->connection = tracker_sparql_connection_bus_new (TRACKER_MINER_FS_BUSNAME, NULL, NULL, &error); if (error) { |