[tracker/collation-gconf-locale: 12/30] libtracker-data: WIP with collator reset
- From: Aleksander Morgado <aleksm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/collation-gconf-locale: 12/30] libtracker-data: WIP with collator reset
- Date: Wed, 17 Nov 2010 12:28:48 +0000 (UTC)
commit 1156739243ff81d547f72aff281cc2717eeeaba3
Author: Aleksander Morgado <aleksander lanedo com>
Date: Thu Oct 28 17:28:52 2010 +0200
libtracker-data: WIP with collator reset
src/libtracker-data/tracker-data-manager.c | 1 +
src/libtracker-data/tracker-db-interface-sqlite.c | 43 ++++++++++++++++++--
2 files changed, 39 insertions(+), 5 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index c29b9c8..1140023 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -3205,6 +3205,7 @@ tracker_data_manager_reload (TrackerBusyCallback busy_callback,
flags = tracker_db_manager_get_flags (&select_cache_size, &update_cache_size);
tracker_data_manager_shutdown ();
+ /* And initialize it again, this actually triggers index recreation. */
return tracker_data_manager_init (flags,
NULL,
&is_first,
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c b/src/libtracker-data/tracker-db-interface-sqlite.c
index 9d7c5ab..3673663 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -57,7 +57,10 @@ struct TrackerDBInterface {
GSList *function_data;
+ /* Collation and locale change */
gpointer collator;
+ gpointer locale_notification_id;
+ gboolean collator_reset_requested;
guint ro : 1;
#if HAVE_TRACKER_FTS
@@ -527,6 +530,16 @@ check_interrupt (void *user_data)
}
static void
+tracker_locale_notify_cb (TrackerLocaleID id,
+ gpointer user_data)
+{
+ TrackerDBInterface *db_interface = user_data;
+
+ /* Request a collator reset. */
+ db_interface->collator_reset_requested = TRUE;
+}
+
+static void
open_database (TrackerDBInterface *db_interface)
{
int mode;
@@ -546,9 +559,12 @@ open_database (TrackerDBInterface *db_interface)
}
/* Set our unicode collation function */
- if (!db_interface->collator) {
- tracker_db_interface_sqlite_reset_collator (db_interface);
- }
+ tracker_db_interface_sqlite_reset_collator (db_interface);
+ /* And register for updates on locale changes */
+ db_interface->locale_notification_id = tracker_locale_notify_add (TRACKER_LOCALE_COLLATE,
+ tracker_locale_notify_cb,
+ db_interface,
+ NULL);
sqlite3_progress_handler (db_interface->db, 100,
check_interrupt, db_interface);
@@ -730,6 +746,8 @@ tracker_db_interface_sqlite_reset_collator (TrackerDBInterface *db_interface)
}
}
+
+
static void
tracker_db_interface_sqlite_finalize (GObject *object)
{
@@ -744,6 +762,7 @@ tracker_db_interface_sqlite_finalize (GObject *object)
g_free (db_interface->filename);
g_free (db_interface->busy_status);
+ tracker_locale_notify_remove (db_interface->locale_notification_id);
tracker_collation_shutdown (db_interface->collator);
G_OBJECT_CLASS (tracker_db_interface_parent_class)->finalize (object);
@@ -1102,8 +1121,14 @@ create_result_set_from_stmt (TrackerDBInterface *interface,
}
}
- if (result != SQLITE_DONE) {
-
+ if (result == SQLITE_DONE) {
+ /* Statement finished, check if we got a request to reset the
+ * collator, and if so, do it. */
+ if (interface->collator_reset_requested) {
+ tracker_db_interface_sqlite_reset_collator (interface);
+ interface->collator_reset_requested = FALSE;
+ }
+ } else {
/* This is rather fatal */
if (sqlite3_errcode (interface->db) == SQLITE_IOERR ||
sqlite3_errcode (interface->db) == SQLITE_CORRUPT ||
@@ -1529,6 +1554,14 @@ db_cursor_iter_next (TrackerDBCursor *cursor,
cursor->finished = (result != SQLITE_ROW);
}
+ /* Statement finished, check if we got a request to reset the
+ * collator, and if so, do it. */
+ if (cursor->finished &&
+ iface->collator_reset_requested) {
+ tracker_db_interface_sqlite_reset_collator (iface);
+ iface->collator_reset_requested = FALSE;
+ }
+
return (!cursor->finished);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]