[tracker/checkpoint] libtracker-data: Reimplement restoring fts
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/checkpoint] libtracker-data: Reimplement restoring fts
- Date: Tue, 28 Jun 2011 08:23:52 +0000 (UTC)
commit 24b2e773ec673124d9f951c51147ca5ba9f2f1ab
Author: Philip Van Hoof <philip codeminded be>
Date: Tue Jun 28 10:20:03 2011 +0200
libtracker-data: Reimplement restoring fts
src/libtracker-data/tracker-db-backup.c | 77 ++++++++++++++++++++-----------
1 files changed, 50 insertions(+), 27 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-backup.c b/src/libtracker-data/tracker-db-backup.c
index 212f313..395f85e 100644
--- a/src/libtracker-data/tracker-db-backup.c
+++ b/src/libtracker-data/tracker-db-backup.c
@@ -28,6 +28,7 @@
#include <sqlite3.h>
#include <libtracker-data/tracker-ontology.h>
+#include <libtracker-data/tracker-ontologies.h>
#include <libtracker-data/tracker-db-manager.h>
#include <libtracker-data/tracker-db-interface-sqlite.h>
@@ -242,13 +243,16 @@ tracker_db_backup_save (GFile *destination,
void
tracker_db_backup_sync_fts (void)
-{
- TrackerProperty **properties, **property;
+{/*
+ TrackerProperty **properties;
TrackerDBInterface *iface;
TrackerDBStatement *stmt;
TrackerDBCursor *cursor;
TrackerClass *prop_class;
gchar *query;
+ guint n_props = 0, i;
+ TrackerProperty *property;
+ GError *error = NULL;
iface = tracker_db_manager_get_db_interface ();
@@ -260,54 +264,73 @@ tracker_db_backup_sync_fts (void)
tracker_db_interface_execute_query (iface, NULL, "%s", query);
g_free (query);
- properties = tracker_ontology_get_properties ();
- for (property = properties; *property; property++) {
- if (tracker_property_get_data_type (*property) == TRACKER_PROPERTY_TYPE_STRING &&
- tracker_property_get_fulltext_indexed (*property)) {
+ properties = tracker_ontologies_get_properties (&n_props);
+
+ for (i = 0; i < n_props; i++) {
+
+ property = properties[i];
+
+ if (tracker_property_get_data_type (property) == TRACKER_PROPERTY_TYPE_STRING &&
+ tracker_property_get_fulltext_indexed (property)) {
- prop_class = tracker_property_get_domain (*property);
+ prop_class = tracker_property_get_domain (property);
- if (tracker_property_get_multiple_values (*property)) {
- query = g_strdup_printf ("SELECT ID, \"%s\" FROM \"%s_%s\"",
- tracker_property_get_name (*property),
+ if (tracker_property_get_multiple_values (property)) {
+ query = g_strdup_printf ("SELECT ID, \"%s\" FROM \"%s_%s\"",
+ tracker_property_get_name (property),
tracker_class_get_name (prop_class),
- tracker_property_get_name (*property));
+ tracker_property_get_name (property));
} else {
query = g_strdup_printf ("SELECT ID, \"%s\" FROM \"%s\" WHERE \"%s\" IS NOT NULL",
- tracker_property_get_name (*property),
+ tracker_property_get_name (property),
tracker_class_get_name (prop_class),
- tracker_property_get_name (*property));
+ tracker_property_get_name (property));
}
- stmt = tracker_db_interface_create_statement (iface, "%s", query);
- cursor = tracker_db_statement_start_cursor (stmt, NULL);
+ stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_NONE,
+ &error,
+ "%s", query);
+ g_free (query);
+
+ if (error) {
+ g_critical ("%s\n", error->message);
+ g_clear_error (&error);
+ goto fail;
+ }
+
+ cursor = tracker_db_statement_start_cursor (stmt, &error);
g_object_unref (stmt);
if (cursor) {
- while (tracker_db_cursor_iter_next (cursor)) {
+ while (tracker_db_cursor_iter_next (cursor, NULL, &error)) {
guint32 id;
const gchar *text;
+ glong strl;
id = tracker_db_cursor_get_int (cursor, 0);
- text = tracker_db_cursor_get_string (cursor, 1);
+ text = tracker_db_cursor_get_string (cursor, 1, &strl);
- // TODO we need to retrieve all existing (FTS indexed) property values for
- // this resource to properly support incremental FTS updates
- // (like calling deleteTerms and then calling insertTerms)
+ tracker_db_interface_sqlite_fts_update_init (iface, id);
- tracker_fts_update_init (id);
- tracker_fts_update_text (id, 0, text);
+ tracker_db_interface_sqlite_fts_update_text (iface,
+ id,
+ 0,
+ text,
+ FALSE);
}
-
g_object_unref (cursor);
+ } else {
+ g_critical ("%s\n", error->message);
+ * tracker_db_interface_sqlite_fts_update_rollback (iface); *
+ g_clear_error (&error);
+ goto fail;
}
-
- g_free (query);
}
}
- g_free (properties);
- tracker_fts_update_commit ();
+fail:
+
+ tracker_db_interface_sqlite_fts_update_commit (iface);*/
}
#endif /* HAVE_TRACKER_FTS */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]