[tracker/journal] libtracker-data: Fix journal replay with insert/delete mix
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/journal] libtracker-data: Fix journal replay with insert/delete mix
- Date: Tue, 16 Mar 2010 15:09:31 +0000 (UTC)
commit 29f8619a4022e32fad317018be3941c9d66a8256
Author: Jürg Billeter <j bitron ch>
Date: Tue Mar 16 12:34:27 2010 +0100
libtracker-data: Fix journal replay with insert/delete mix
src/libtracker-data/tracker-data-update.c | 45 +++++++++++++++++++++++++++--
1 files changed, 42 insertions(+), 3 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 44b7374..e1fe1c1 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -2472,6 +2472,7 @@ tracker_data_replay_journal (GHashTable *classes,
{
GError *journal_error = NULL;
static TrackerProperty *rdf_type = NULL;
+ gint last_operation_type = 0;
if (!rdf_type) {
rdf_type = tracker_ontologies_get_property_by_uri (RDF_PREFIX "type");
@@ -2524,22 +2525,30 @@ tracker_data_replay_journal (GHashTable *classes,
} else if (type == TRACKER_DB_JOURNAL_END_TRANSACTION) {
tracker_data_commit_transaction ();
} else if (type == TRACKER_DB_JOURNAL_INSERT_STATEMENT) {
+ GError *new_error = NULL;
TrackerProperty *property;
+ if (last_operation_type == -1) {
+ tracker_data_update_buffer_flush (&new_error);
+ if (new_error) {
+ g_warning ("Journal replay error: '%s'", new_error->message);
+ g_clear_error (&new_error);
+ }
+ }
+ last_operation_type = 1;
+
tracker_db_journal_reader_get_statement (&graph_id, &subject_id, &predicate_id, &object);
property = g_hash_table_lookup (properties, GINT_TO_POINTER (predicate_id));
if (property) {
- GError *new_error = NULL;
-
resource_buffer_switch (NULL, graph_id, NULL, subject_id);
cache_set_metadata_decomposed (property, object, 0, NULL, graph_id, &new_error);
if (new_error) {
g_warning ("Journal replay error: '%s'", new_error->message);
- g_error_free (new_error);
+ g_clear_error (&new_error);
}
} else {
@@ -2547,9 +2556,19 @@ tracker_data_replay_journal (GHashTable *classes,
}
} else if (type == TRACKER_DB_JOURNAL_INSERT_STATEMENT_ID) {
+ GError *new_error = NULL;
TrackerClass *class = NULL;
TrackerProperty *property;
+ if (last_operation_type == -1) {
+ tracker_data_update_buffer_flush (&new_error);
+ if (new_error) {
+ g_warning ("Journal replay error: '%s'", new_error->message);
+ g_clear_error (&new_error);
+ }
+ }
+ last_operation_type = 1;
+
tracker_db_journal_reader_get_statement_id (&graph_id, &subject_id, &predicate_id, &object_id);
property = g_hash_table_lookup (properties, GINT_TO_POINTER (predicate_id));
@@ -2585,8 +2604,18 @@ tracker_data_replay_journal (GHashTable *classes,
}
} else if (type == TRACKER_DB_JOURNAL_DELETE_STATEMENT) {
+ GError *new_error = NULL;
TrackerProperty *property;
+ if (last_operation_type == 1) {
+ tracker_data_update_buffer_flush (&new_error);
+ if (new_error) {
+ g_warning ("Journal replay error: '%s'", new_error->message);
+ g_clear_error (&new_error);
+ }
+ }
+ last_operation_type = -1;
+
tracker_db_journal_reader_get_statement (&graph_id, &subject_id, &predicate_id, &object);
resource_buffer_switch (NULL, graph_id, NULL, subject_id);
@@ -2619,9 +2648,19 @@ tracker_data_replay_journal (GHashTable *classes,
}
} else if (type == TRACKER_DB_JOURNAL_DELETE_STATEMENT_ID) {
+ GError *new_error = NULL;
TrackerClass *class = NULL;
TrackerProperty *property;
+ if (last_operation_type == 1) {
+ tracker_data_update_buffer_flush (&new_error);
+ if (new_error) {
+ g_warning ("Journal replay error: '%s'", new_error->message);
+ g_clear_error (&new_error);
+ }
+ }
+ last_operation_type = -1;
+
tracker_db_journal_reader_get_statement_id (&graph_id, &subject_id, &predicate_id, &object_id);
property = g_hash_table_lookup (properties, GINT_TO_POINTER (predicate_id));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]