[tracker-miners/wip/carlosg/volume-indexing-fixes: 3/6] tracker-miner-fs: Fix mountpoint maintenance queries




commit 3cec785edaae37896b0eed940f5b77e369baaf70
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Aug 9 21:58:33 2020 +0200

    tracker-miner-fs: Fix mountpoint maintenance queries
    
    Use the correct tracker:FileSystem graph, and ensure that
    tracker:unmountDate/tracker:available are either set/false in
    the case of an unmounted volume, or unset/true for a present
    volume.
    
    Since the queries are not that much different, make the shared
    query bits common in code.

 src/miners/fs/tracker-miner-files.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)
---
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index 5eab1291f..10b2811e3 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -799,20 +799,17 @@ set_up_mount_point (TrackerMinerFiles *miner,
        GString *queries;
        gchar *uri;
 
-       queries = g_string_new (NULL);
+       queries = g_string_new ("WITH " DEFAULT_GRAPH " ");
        uri = g_file_get_uri (mount_point);
 
        if (mounted) {
                g_debug ("Mount point state (MOUNTED) being set in DB for mount_point '%s'",
                         uri);
 
-               g_string_append_printf (queries,
-                                       "DELETE { ?u tracker:unmountDate ?d } "
-                                       "WHERE { <%s> a nfo:FileDataObject ; "
-                                       "             nie:interpretedAs/"
-                                       "             nie:rootElementOf ?u"
-                                       "}",
-                                       uri);
+               g_string_append (queries,
+                                "DELETE { ?u tracker:unmountDate ?date ;"
+                                "            tracker:available ?avail } "
+                                "INSERT { ?u tracker:available true } ");
        } else {
                gchar *now;
 
@@ -822,18 +819,23 @@ set_up_mount_point (TrackerMinerFiles *miner,
                now = tracker_date_to_string (time (NULL));
 
                g_string_append_printf (queries,
-                                       "DELETE { ?u tracker:unmountDate ?unknown1 ;"
-                                       "            tracker:available ?unknown2 } "
-                                       "INSERT { ?u tracker:unmountDate \"%s\" } "
-                                       "WHERE { <%s> a nfo:FileDataObject ; "
-                                       "             nie:interpretedAs/"
-                                       "             nie:rootElementOf ?u"
-                                       "}",
-                                       now, uri);
+                                       "DELETE { ?u tracker:unmountDate ?date ;"
+                                       "            tracker:available ?avail } "
+                                       "INSERT { ?u tracker:unmountDate \"%s\" ; "
+                                       "            tracker:available false } ",
+                                       now);
 
                g_free (now);
        }
 
+       g_string_append_printf (queries,
+                               "WHERE { <%s> a nfo:FileDataObject ; "
+                               "             nie:interpretedAs/"
+                               "             nie:rootElementOf ?u . "
+                               "        ?u tracker:available ?avail . "
+                               "        OPTIONAL { ?u tracker:unmountDate ?date } "
+                               "}",
+                               uri);
        g_free (uri);
 
        if (accumulator) {


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