[tracker/journal-test] libtracker-data: Test patch to fix journal replay with insert/delete mix



commit 921e2ebc59a6491bc551bdfef136af25379553ca
Author: Jürg Billeter <j bitron ch>
Date:   Tue Mar 16 12:34:27 2010 +0100

    libtracker-data: Test patch to 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 cd89380..e9d4d4e 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");
@@ -2515,22 +2516,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_blank_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 {
@@ -2538,9 +2547,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_blank_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));
@@ -2576,8 +2595,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_blank_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);
@@ -2610,9 +2639,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_blank_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]