[gnome-music/wip/mschraal/tracker-detection: 14/18] trackerwrapper: Add version check



commit e11f112edee87d593ab54bc08e6f5c8e90f4fefa
Author: Marinus Schraal <mschraal gnome org>
Date:   Tue Jul 23 17:25:39 2019 +0200

    trackerwrapper: Add version check
    
    By executing a simple query with syntax added in Tracker 2.2.0 it is possible
    to check if the Tracker version used is recent enough.

 gnomemusic/trackerwrapper.py | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/trackerwrapper.py b/gnomemusic/trackerwrapper.py
index 2c57b6ae..f5cfc70c 100644
--- a/gnomemusic/trackerwrapper.py
+++ b/gnomemusic/trackerwrapper.py
@@ -50,7 +50,26 @@ class TrackerWrapper(GObject.GObject):
             self.notify("tracker-available")
             return
 
-        self._tracker_available = True
+        query = """
+        SELECT
+            ?o
+        WHERE
+        {
+            ?o nfo:belongsToContainer/nie:url 'file:///' .
+        }
+        """.replace("\n", " ").strip()
+
+        self._tracker.query_async(
+            query, None, self._query_version_check)
+
+    def _query_version_check(self, klass, result):
+        try:
+            klass.query_finish(result)
+            self._tracker_available = True
+        except GLib.Error as error:
+            logger.warning("Error: {}, {}".format(error.domain, error.message))
+            self._tracker_available = False
+
         self.notify("tracker-available")
 
     @GObject.Property(type=object, flags=GObject.ParamFlags.READABLE)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]