[tracker/extraction-improvements: 2/3] tracker-miner-fs: Move "retry on extraction failed" code to TrackerMinerFiles



commit f1924b2afa1b0eae7acdfecffec0876db4c98a55
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed May 4 15:18:47 2011 +0200

    tracker-miner-fs: Move "retry on extraction failed" code to TrackerMinerFiles
    
    Currently the simplest approach of retrying just once
    every failed file is taken, after that, the sparql without
    embedded metadata is added.

 src/libtracker-miner/tracker-miner-fs.c |   33 +++-------------------
 src/miners/fs/tracker-miner-files.c     |   44 ++++++++++++++++++++++++++++--
 2 files changed, 46 insertions(+), 31 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index e0dff01..022771e 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -1644,37 +1644,14 @@ item_add_or_update_cb (TrackerMinerFS        *fs,
 	uri = g_file_get_uri (task_file);
 
 	if (error) {
-		TrackerProcessingTask *first_item_task;
+		g_message ("Could not process '%s': %s", uri, error->message);
 
-		first_item_task = tracker_processing_pool_get_last_wait (fs->private->processing_pool);
+		fs->private->total_files_notified_error++;
 
-		/* Perhaps this is too specific to TrackerMinerFiles, if the extractor
-		 * is choking on some file, the miner will get a timeout for all files
-		 * being currently processed, but the one that is actually causing it
-		 * is the first one that was added to the processing pool, so we retry
-		 * the others.
-		 */
-		if (task != first_item_task &&
-		    (error->code == G_DBUS_ERROR_NO_REPLY ||
-		     error->code == G_DBUS_ERROR_TIMEOUT ||
-		     error->code == G_DBUS_ERROR_TIMED_OUT)) {
-			g_debug ("  Got DBus timeout error on '%s', but it could not be caused by it. Retrying file.", uri);
-
-			/* Reset the TrackerSparqlBuilder */
-			g_object_unref (ctxt->builder);
-			ctxt->builder = tracker_sparql_builder_new_update ();
-
-			do_process_file (fs, task);
-		} else {
-			g_message ("Could not process '%s': %s", uri, error->message);
-
-			fs->private->total_files_notified_error++;
+		tracker_processing_pool_remove_task (fs->private->processing_pool, task);
+		tracker_processing_task_free (task);
 
-			tracker_processing_pool_remove_task (fs->private->processing_pool, task);
-			tracker_processing_task_free (task);
-
-			item_queue_handlers_set_up (fs);
-		}
+		item_queue_handlers_set_up (fs);
 	} else {
 		if (ctxt->urn) {
 			gboolean attribute_update_only;
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index 7551862..b857d13 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -64,6 +64,8 @@ struct ProcessFileData {
 	TrackerSparqlBuilder *sparql;
 	GCancellable *cancellable;
 	GFile *file;
+	gchar *mime_type;
+	guint retried : 1;
 };
 
 struct TrackerMinerFilesPrivate {
@@ -1901,6 +1903,7 @@ process_file_data_free (ProcessFileData *data)
 	g_object_unref (data->sparql);
 	g_object_unref (data->cancellable);
 	g_object_unref (data->file);
+	g_free (data->mime_type);
 	g_slice_free (ProcessFileData, data);
 }
 
@@ -1918,9 +1921,42 @@ extractor_get_embedded_metadata_cb (GObject      *object,
 	info = tracker_extract_client_get_metadata_finish (G_FILE (object), res, &error);
 
 	if (error) {
-		/* 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);
+		if (error->code == G_DBUS_ERROR_NO_REPLY ||
+		    error->code == G_DBUS_ERROR_TIMEOUT ||
+		    error->code == G_DBUS_ERROR_TIMED_OUT) {
+			gchar *uri;
+
+			uri = g_file_get_uri (data->file);
+
+			if (!data->retried) {
+				data->retried = TRUE;
+
+				g_debug ("  Got extraction DBus error on '%s'. Retrying file.", uri);
+
+				/* Try again extraction */
+				tracker_extract_client_get_metadata (data->file,
+				                                     data->mime_type,
+				                                     data->cancellable,
+				                                     extractor_get_embedded_metadata_cb,
+				                                     data);
+			} else {
+				g_warning ("  Got second extraction DBus error on '%s'. "
+				           "Adding only non-embedded metadata to the SparQL, "
+				           "the error was: %s",
+				           uri, error->message);
+
+				tracker_miner_fs_file_notify (TRACKER_MINER_FS (data->miner), data->file, NULL);
+				process_file_data_free (data);
+			}
+
+			g_free (uri);
+		} else {
+			/* 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);
+		}
+
+		g_error_free (error);
 		return;
 	}
 
@@ -2037,6 +2073,8 @@ process_file_cb (GObject      *object,
 	mime_type = g_file_info_get_content_type (file_info);
 	urn = miner_files_get_file_urn (TRACKER_MINER_FILES (data->miner), file, &is_iri);
 
+	data->mime_type = g_strdup (mime_type);
+
 	tracker_sparql_builder_insert_silent_open (sparql, NULL);
 	tracker_sparql_builder_graph_open (sparql, TRACKER_MINER_FS_GRAPH_URN);
 



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