[tracker/nb263203] libtracker-data: Do not begin ontology transaction when not needed



commit 5ee7262fac2551b58f7dea84f8a5b269773200ac
Author: JÃrg Billeter <j bitron ch>
Date:   Wed Jun 15 17:28:26 2011 +0200

    libtracker-data: Do not begin ontology transaction when not needed
    
    This allows tracker-store startup with full partition. Updates will fail
    as long as partition is full.
    
    Fixes NB#263203.

 src/libtracker-data/tracker-data-manager.c |   37 ++++++++++++++++++++-------
 1 files changed, 27 insertions(+), 10 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index ff9da8a..217490f 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -3760,6 +3760,7 @@ tracker_data_manager_init (TrackerDBManagerFlags   flags,
 		GPtrArray *seen_classes;
 		GPtrArray *seen_properties;
 		GError *n_error = NULL;
+		gboolean transaction_started = FALSE;
 
 		seen_classes = g_ptr_array_new ();
 		seen_properties = g_ptr_array_new ();
@@ -3786,12 +3787,6 @@ tracker_data_manager_init (TrackerDBManagerFlags   flags,
 
 		/* check ontology against database */
 
-		tracker_data_begin_ontology_transaction (&internal_error);
-		if (internal_error) {
-			g_propagate_error (error, internal_error);
-			return FALSE;
-		}
-
 		/* Get a map of tracker:Ontology v. nao:lastModified so that we can test
 		 * for all the ontology files in ontologies_dir whether the last-modified
 		 * has changed since we dealt with the file last time. */
@@ -3868,6 +3863,16 @@ tracker_data_manager_init (TrackerDBManagerFlags   flags,
 				 * modified in the latest version of the file, deal with changes. */
 				if (val != last_mod) {
 					g_debug ("Ontology file '%s' needs update", ontology_path);
+
+					if (!transaction_started) {
+						tracker_data_begin_ontology_transaction (&internal_error);
+						if (internal_error) {
+							g_propagate_error (error, internal_error);
+							return FALSE;
+						}
+						transaction_started = TRUE;
+					}
+
 					if (max_id == 0) {
 						/* In case of first-time, this wont start at zero */
 						max_id = get_new_service_id (iface);
@@ -3934,6 +3939,16 @@ tracker_data_manager_init (TrackerDBManagerFlags   flags,
 				GError *ontology_error = NULL;
 
 				g_debug ("Ontology file '%s' got added", ontology_path);
+
+				if (!transaction_started) {
+					tracker_data_begin_ontology_transaction (&internal_error);
+					if (internal_error) {
+						g_propagate_error (error, internal_error);
+						return FALSE;
+					}
+					transaction_started = TRUE;
+				}
+
 				if (max_id == 0) {
 					/* In case of first-time, this wont start at zero */
 					max_id = get_new_service_id (iface);
@@ -4105,10 +4120,12 @@ tracker_data_manager_init (TrackerDBManagerFlags   flags,
 		/* Reset the is_new flag for all classes and properties */
 		tracker_data_ontology_import_finished ();
 
-		tracker_data_commit_transaction (&internal_error);
-		if (internal_error) {
-			g_propagate_error (error, internal_error);
-			return FALSE;
+		if (transaction_started) {
+			tracker_data_commit_transaction (&internal_error);
+			if (internal_error) {
+				g_propagate_error (error, internal_error);
+				return FALSE;
+			}
 		}
 
 		g_hash_table_unref (ontos_table);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]