[tracker/extraction-improvements: 3/5] tracker-miner-fs: Move "retry on extraction failed" code to TrackerMinerFiles
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/extraction-improvements: 3/5] tracker-miner-fs: Move "retry on extraction failed" code to TrackerMinerFiles
- Date: Fri, 17 Jun 2011 15:41:40 +0000 (UTC)
commit a8f237f8f35bb2616c5829c031bdf47e00c170ad
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 | 37 ++----------
src/miners/fs/tracker-miner-files.c | 96 +++++++++++++++++++++++--------
2 files changed, 78 insertions(+), 55 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index f1dc5ce..8295037 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -1671,43 +1671,20 @@ 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->priv->processing_pool);
+ fs->priv->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->priv->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;
attribute_update_only = GPOINTER_TO_INT (g_object_steal_qdata (G_OBJECT (task_file),
- fs->private->quark_attribute_updated));
+ fs->priv->quark_attribute_updated));
g_debug ("Updating item '%s' with urn '%s'%s",
uri,
ctxt->urn,
@@ -1760,7 +1737,7 @@ item_add_or_update_cb (TrackerMinerFS *fs,
/* 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,
+ if (!tracker_processing_pool_push_ready_task (fs->priv->processing_pool,
task,
processing_pool_task_finished_cb,
fs)) {
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index dab81a9..043adba 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 {
@@ -1904,37 +1906,18 @@ 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);
}
static void
-extractor_get_embedded_metadata_cb (GObject *object,
- GAsyncResult *res,
- gpointer user_data)
+sparql_builder_finish (ProcessFileData *data,
+ const gchar *preupdate,
+ const gchar *sparql,
+ const gchar *where)
{
- ProcessFileData *data = user_data;
- const gchar *preupdate, *sparql, *where;
- TrackerExtractInfo *info;
- GError *error = NULL;
const gchar *uuid;
- if (res) {
- 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);
- return;
- }
-
- preupdate = tracker_extract_info_get_preupdate (info);
- sparql = tracker_extract_info_get_update (info);
- where = tracker_extract_info_get_where_clause (info);
- } else {
- preupdate = sparql = where = NULL;
- }
-
if (sparql && *sparql) {
gboolean is_iri;
const gchar *urn;
@@ -2004,6 +1987,66 @@ extractor_get_embedded_metadata_cb (GObject *object,
g_free (removable_device_urn);
g_free (uri);
}
+}
+
+static void
+extractor_get_embedded_metadata_cb (GObject *object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ ProcessFileData *data = user_data;
+ const gchar *preupdate, *sparql, *where;
+ TrackerExtractInfo *info;
+ GError *error = NULL;
+
+ info = tracker_extract_client_get_metadata_finish (G_FILE (object), res, &error);
+
+ if (error) {
+ 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);
+
+ sparql_builder_finish (data, NULL, NULL, NULL);
+ 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;
+ }
+
+ preupdate = tracker_extract_info_get_preupdate (info);
+ sparql = tracker_extract_info_get_update (info);
+ where = tracker_extract_info_get_where_clause (info);
+
+ sparql_builder_finish (data, preupdate, sparql, where);
/* Notify about the success */
tracker_miner_fs_file_notify (TRACKER_MINER_FS (data->miner), data->file, NULL);
@@ -2044,6 +2087,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);
@@ -2111,7 +2156,8 @@ process_file_cb (GObject *object,
} else {
/* Otherwise, don't request embedded metadata extraction. */
g_debug ("Avoiding embedded metadata request for uri '%s'", uri);
- extractor_get_embedded_metadata_cb (NULL, NULL, user_data);
+ sparql_builder_finish (data, NULL, NULL, NULL);
+ tracker_miner_fs_file_notify (TRACKER_MINER_FS (data->miner), data->file, NULL);
}
g_object_unref (file_info);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]