[tracker/ontology-cope-for-master: 7/11] libtracker-data: Bugfix coping with modest ontology changes
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/ontology-cope-for-master: 7/11] libtracker-data: Bugfix coping with modest ontology changes
- Date: Mon, 22 Feb 2010 14:16:00 +0000 (UTC)
commit b8cfe3e1323f49570ec73bfffcb0352fe0a4c530
Author: Philip Van Hoof <philip codeminded be>
Date: Thu Feb 18 15:31:05 2010 +0100
libtracker-data: Bugfix coping with modest ontology changes
The max_id cache of tracker-data-update.c shouldn't be intermixed with the
max_ids of tracker-data-manager.c, or should be reset afterward. I decided
to keep it simple and just copy the function, and that way don't have to
reset the max_id cache of tracker-data-update.c
src/libtracker-data/tracker-data-manager.c | 33 +++++++++++++++++++++++++++-
src/libtracker-data/tracker-data-update.c | 2 +-
src/libtracker-data/tracker-data-update.h | 1 -
3 files changed, 33 insertions(+), 3 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 79093fb..842b491 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -1480,6 +1480,37 @@ get_ontologies (gboolean test_schema,
}
+static gint
+get_new_service_id (TrackerDBInterface *iface)
+{
+ TrackerDBCursor *cursor;
+ TrackerDBStatement *stmt;
+
+ /* Don't intermix this thing with tracker_data_update_get_new_service_id,
+ * if you use this, know what you are doing! */
+
+ static gint max = 0;
+
+ if (G_LIKELY (max != 0)) {
+ return ++max;
+ }
+
+ iface = tracker_db_manager_get_db_interface ();
+
+ stmt = tracker_db_interface_create_statement (iface,
+ "SELECT MAX(ID) AS A FROM Resource");
+ cursor = tracker_db_statement_start_cursor (stmt, NULL);
+ g_object_unref (stmt);
+
+ if (cursor) {
+ tracker_db_cursor_iter_next (cursor);
+ max = MAX (tracker_db_cursor_get_int (cursor, 0), max);
+ g_object_unref (cursor);
+ }
+
+ return ++max;
+}
+
gboolean
tracker_data_manager_init (TrackerDBManagerFlags flags,
const gchar *test_schema,
@@ -1679,7 +1710,7 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
if (max_id == 0) {
/* In case of first-time, this wont start at zero */
- max_id = tracker_data_update_get_new_service_id ();
+ max_id = get_new_service_id (iface);
}
load_ontology_file (ontology_file, &max_id, TRUE);
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 9687cd6..35c9c12 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -198,7 +198,7 @@ GQuark tracker_data_error_quark (void) {
return g_quark_from_static_string ("tracker_data_error-quark");
}
-gint
+static gint
tracker_data_update_get_new_service_id (void)
{
TrackerDBCursor *cursor;
diff --git a/src/libtracker-data/tracker-data-update.h b/src/libtracker-data/tracker-data-update.h
index 8ab9216..da3d429 100644
--- a/src/libtracker-data/tracker-data-update.h
+++ b/src/libtracker-data/tracker-data-update.h
@@ -51,7 +51,6 @@ typedef void (*TrackerStatementCallback) (const gchar *graph,
typedef void (*TrackerCommitCallback) (gpointer user_data);
GQuark tracker_data_error_quark (void);
-gint tracker_data_update_get_new_service_id (void);
/* Metadata */
void tracker_data_delete_resource_description (const gchar *graph,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]