[tracker] miners/fs, libtracker-miner: On extractor error insert minimal FS info of the file



commit 3dd75bacc30b30253c4e439202cea8a1f0dee6b2
Author: Philip Van Hoof <philip codeminded be>
Date:   Mon May 2 15:19:43 2011 +0200

    miners/fs, libtracker-miner: On extractor error insert minimal FS info of the file
    
    This commit can be ported to tracker-0.10
    
    Fixes NB#249338.

 src/libtracker-miner/tracker-miner-fs.c |  120 +++++++++++++++++--------------
 src/miners/fs/tracker-miner-files.c     |    3 +
 2 files changed, 68 insertions(+), 55 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index e0dff01..600dda5 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -1665,71 +1665,81 @@ item_add_or_update_cb (TrackerMinerFS        *fs,
 			ctxt->builder = tracker_sparql_builder_new_update ();
 
 			do_process_file (fs, task);
-		} else {
-			g_message ("Could not process '%s': %s", uri, error->message);
+			g_free (uri);
+
+			return;
 
+		} else {
 			fs->private->total_files_notified_error++;
+			g_message ("Could not process '%s': %s",
+			            uri,
+			            error->message ? error->message : "No error given");
+		}
+	}
 
-			tracker_processing_pool_remove_task (fs->private->processing_pool, task);
-			tracker_processing_task_free (task);
+	if (ctxt->urn) {
+		gboolean attribute_update_only;
 
-			item_queue_handlers_set_up (fs);
+		attribute_update_only = GPOINTER_TO_INT (g_object_steal_qdata (G_OBJECT (task_file),
+		                                                               fs->private->quark_attribute_updated));
+		g_debug ("Updating item%s%s%s '%s' with urn '%s'%s",
+		         error != NULL ? " (which had extractor error '" : "",
+		         error != NULL ? (error->message ? error->message : "No error given") : "",
+		         error != NULL ? "')" : "",
+		         uri,
+		         ctxt->urn,
+		         attribute_update_only ? " (attributes only)" : "");
+
+		if (!attribute_update_only) {
+			gchar *full_sparql;
+
+			/* update, delete all statements inserted by miner
+			 * except for rdf:type statements as they could cause implicit deletion of user data */
+			full_sparql = g_strdup_printf ("DELETE {"
+			                               "  GRAPH <%s> {"
+			                               "    <%s> ?p ?o"
+			                               "  } "
+			                               "} "
+			                               "WHERE {"
+			                               "  GRAPH <%s> {"
+			                               "    <%s> ?p ?o"
+			                               "    FILTER (?p != rdf:type && ?p != nie:contentCreated)"
+			                               "  } "
+			                               "} "
+			                               "%s",
+			                               TRACKER_MINER_FS_GRAPH_URN,
+			                               ctxt->urn,
+			                               TRACKER_MINER_FS_GRAPH_URN,
+			                               ctxt->urn,
+			                               tracker_sparql_builder_get_result (ctxt->builder));
+
+			/* Note that set_sparql_string() takes ownership of the passed string */
+			tracker_processing_task_set_sparql_string (task, full_sparql);
+		} else {
+			/* Do not drop graph if only updating attributes, the SPARQL builder
+			 * will already contain the necessary DELETE statements for the properties
+			 * being updated */
+			tracker_processing_task_set_sparql (task, ctxt->builder);
 		}
 	} else {
-		if (ctxt->urn) {
-			gboolean attribute_update_only;
-
-			attribute_update_only = GPOINTER_TO_INT (g_object_steal_qdata (G_OBJECT (task_file),
-			                                                               fs->private->quark_attribute_updated));
-			g_debug ("Updating item '%s' with urn '%s'%s",
+		if (error != NULL) {
+			g_debug ("Creating minimal info for new item '%s' which had error: '%s'",
 			         uri,
-			         ctxt->urn,
-			         attribute_update_only ? " (attributes only)" : "");
-
-			if (!attribute_update_only) {
-				gchar *full_sparql;
-
-				/* update, delete all statements inserted by miner
-				 * except for rdf:type statements as they could cause implicit deletion of user data */
-				full_sparql = g_strdup_printf ("DELETE {"
-				                               "  GRAPH <%s> {"
-				                               "    <%s> ?p ?o"
-				                               "  } "
-				                               "} "
-				                               "WHERE {"
-				                               "  GRAPH <%s> {"
-				                               "    <%s> ?p ?o"
-				                               "    FILTER (?p != rdf:type && ?p != nie:contentCreated)"
-				                               "  } "
-				                               "} "
-				                               "%s",
-				                               TRACKER_MINER_FS_GRAPH_URN,
-				                               ctxt->urn,
-				                               TRACKER_MINER_FS_GRAPH_URN,
-				                               ctxt->urn,
-				                               tracker_sparql_builder_get_result (ctxt->builder));
-
-				/* Note that set_sparql_string() takes ownership of the passed string */
-				tracker_processing_task_set_sparql_string (task, full_sparql);
-			} else {
-				/* Do not drop graph if only updating attributes, the SPARQL builder
-				 * will already contain the necessary DELETE statements for the properties
-				 * being updated */
-				tracker_processing_task_set_sparql (task, ctxt->builder);
-			}
+			         error->message ? error->message : "No error given");
 		} else {
 			g_debug ("Creating new item '%s'", uri);
-			tracker_processing_task_set_sparql (task, ctxt->builder);
 		}
 
-		/* If push_ready_task() returns FALSE, it means the actual db update was delayed,
-		 * and in this case we need to setup queue handlers again */
-		if (!tracker_processing_pool_push_ready_task (fs->private->processing_pool,
-		                                              task,
-		                                              processing_pool_task_finished_cb,
-		                                              fs)) {
-			item_queue_handlers_set_up (fs);
-		}
+		tracker_processing_task_set_sparql (task, ctxt->builder);
+	}
+
+	/* If push_ready_task() returns FALSE, it means the actual db update was delayed,
+	 * and in this case we need to setup queue handlers again */
+	if (!tracker_processing_pool_push_ready_task (fs->private->processing_pool,
+	                                              task,
+	                                              processing_pool_task_finished_cb,
+	                                              fs)) {
+		item_queue_handlers_set_up (fs);
 	}
 
 	g_free (uri);
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index 3dd67c5..d465ee2 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -1959,6 +1959,9 @@ extractor_get_embedded_metadata_cb (const gchar *preupdate,
 	const gchar *uuid;
 
 	if (error) {
+		tracker_sparql_builder_graph_close (data->sparql);
+		tracker_sparql_builder_insert_close (data->sparql);
+
 		/* Something bad happened, notify about the error */
 		tracker_miner_fs_file_notify (TRACKER_MINER_FS (data->miner), data->file, error);
 		process_file_data_free (data);



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