From e52493218e3bd20e1b04d930b079a3e912212caf Mon Sep 17 00:00:00 2001 From: John Factotum <50942278+johnfactotum@users.noreply.github.com> Date: Thu, 13 Jan 2022 20:07:57 +0800 Subject: [PATCH] Upgrade to Tracker 3 Fixes #798 --- src/library.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/library.js b/src/library.js index 29b16e10..473efcb6 100644 --- a/src/library.js +++ b/src/library.js @@ -34,9 +34,10 @@ const settings = new Gio.Settings({ schema_id: pkg.name + '.library' }) let trackerConnection if (settings.get_boolean('use-tracker')) { try { - imports.gi.versions.Tracker = '2.0' + imports.gi.versions.Tracker = '3.0' const Tracker = imports.gi.Tracker - trackerConnection = Tracker.SparqlConnection.get(null) + trackerConnection = Tracker.SparqlConnection.bus_new( + 'org.freedesktop.Tracker3.Miner.Files', null, null) } catch(e) {} } @@ -414,7 +415,17 @@ const makeLibraryWidget = (params, widget) => { if (trackerConnection) { // get file url with Tracker try { - const sparql = `SELECT nie:url(?u) WHERE { ?u nie:identifier <${id}> }` + const sparql = ` + SELECT ?uri + WHERE { + SERVICE { + GRAPH tracker:Documents { + ?u rdf:type nfo:EBook . + ?u nie:isStoredAs ?uri . + ?u nie:identifier <${id}> . + } + } + }` const cursor = trackerConnection.query(sparql, null) cursor.next(null) const url = cursor.get_string(0)[0]