[tracker/wip/carlosg/no-fts-logic-error] libtracker-sparql: Do not attempt to rebuild non-existing FTS tables




commit 74cd5a5d1e1b697a1f2718d363348005d82c9022
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Jun 5 00:19:51 2022 +0200

    libtracker-sparql: Do not attempt to rebuild non-existing FTS tables
    
    If a database/ontology has no fulltext-indexed properties, we do not
    create a corresponding FTS table. Likewise, parser/locale updates
    should not attempt to update it, or we will get a "SQL logic error"
    poking non-existing tables.
    
    Closes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2278

 src/libtracker-sparql/core/tracker-data-manager.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---
diff --git a/src/libtracker-sparql/core/tracker-data-manager.c 
b/src/libtracker-sparql/core/tracker-data-manager.c
index 2a29008b8..a1d3843cd 100644
--- a/src/libtracker-sparql/core/tracker-data-manager.c
+++ b/src/libtracker-sparql/core/tracker-data-manager.c
@@ -3866,8 +3866,22 @@ rebuild_fts_tokens (TrackerDataManager  *manager,
                     TrackerDBInterface  *iface,
                     GError             **error)
 {
+       TrackerProperty **properties;
        GHashTableIter iter;
        gchar *graph;
+       gboolean has_fts;
+       guint len, i;
+
+       properties = tracker_ontologies_get_properties (manager->ontologies, &len);
+
+       for (i = 0; i < len; i++) {
+               has_fts |= tracker_property_get_fulltext_indexed (properties[i]);
+               if (has_fts)
+                       break;
+       }
+
+       if (!has_fts)
+               return TRUE;
 
        g_debug ("Rebuilding FTS tokens, this may take a moment...");
        if (!tracker_db_interface_sqlite_fts_rebuild_tokens (iface, "main", error))


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