[tracker/failsafe-extraction-0.10: 3/3] tracker-miner-fs: Avoid multiple calls to extractor_process_failsafe()
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/failsafe-extraction-0.10: 3/3] tracker-miner-fs: Avoid multiple calls to extractor_process_failsafe()
- Date: Fri, 16 Dec 2011 17:09:44 +0000 (UTC)
commit e7be421022de5aa6b0d9febfb1b4dd8d5ec0fc8d
Author: Carlos Garnacho <carlos lanedo com>
Date: Fri Jun 24 15:10:22 2011 +0200
tracker-miner-fs: Avoid multiple calls to extractor_process_failsafe()
The accounting of currently processed files has been also improved, all
to ensure extractor_process_failsafe() is called just once, and tasks
waiting for process_file_cb() don't sneak in and break failsafe
extraction.
Conflicts:
src/miners/fs/tracker-miner-files.c
src/miners/fs/tracker-miner-files.c | 49 +++++++++++++++++++++++++++--------
1 files changed, 38 insertions(+), 11 deletions(-)
---
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index 9cb54ce..fa0e1c9 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -138,6 +138,8 @@ struct TrackerMinerFilesPrivate {
guint failed_extraction_pause_cookie;
GList *extraction_queue;
GList *failed_extraction_queue;
+
+ gboolean failsafe_extraction;
};
enum {
@@ -2055,6 +2057,7 @@ extractor_get_failsafe_metadata_cb (const gchar *preupdate,
{
ProcessFileData *data = user_data;
TrackerMinerFiles *miner = data->miner;
+ TrackerMinerFilesPrivate *priv = miner->private;
gchar *uri;
if (error) {
@@ -2066,7 +2069,6 @@ extractor_get_failsafe_metadata_cb (const gchar *preupdate,
sparql_builder_finish (data, NULL, NULL);
- g_error_free (error);
g_free (uri);
} else {
g_debug (" Extraction succeeded the second time");
@@ -2077,6 +2079,8 @@ extractor_get_failsafe_metadata_cb (const gchar *preupdate,
* again, so we get the essential data in the store.
*/
tracker_miner_fs_file_notify (TRACKER_MINER_FS (miner), data->file, NULL);
+
+ priv->failed_extraction_queue = g_list_remove (priv->failed_extraction_queue, data);
process_file_data_free (data);
/* Get on to the next failed extraction, or resume miner */
@@ -2121,7 +2125,31 @@ extractor_process_failsafe (TrackerMinerFiles *miner)
priv->failed_extraction_pause_cookie = 0;
}
+
+ priv->failsafe_extraction = FALSE;
+ }
+}
+
+static void
+extractor_check_process_failsafe (TrackerMinerFiles *miner)
+{
+ TrackerMinerFilesPrivate *priv;
+
+ priv = miner->private;
+
+ if (priv->failsafe_extraction) {
+ /* already on failsafe extraction */
+ return;
+ }
+
+ if (priv->extraction_queue ||
+ !priv->failed_extraction_queue) {
+ /* No reasons (yet) to start failsafe extraction */
+ return;
}
+
+ priv->failsafe_extraction = TRUE;
+ extractor_process_failsafe (miner);
}
static void
@@ -2147,7 +2175,6 @@ extractor_get_embedded_metadata_cb (const gchar *preupdate,
uri = g_file_get_uri (data->file);
g_warning (" Got extraction DBus error on '%s': %s", uri, error->message);
- /* Pause the miner until we've finished failsafe extraction retry */
if (priv->failed_extraction_pause_cookie != 0) {
priv->failed_extraction_pause_cookie =
tracker_miner_pause (TRACKER_MINER (data->miner),
@@ -2163,8 +2190,6 @@ extractor_get_embedded_metadata_cb (const gchar *preupdate,
tracker_miner_fs_file_notify (TRACKER_MINER_FS (data->miner), data->file, error);
process_file_data_free (data);
}
-
- g_error_free (error);
} else {
sparql_builder_finish (data, preupdate, sparql);
@@ -2176,10 +2201,7 @@ extractor_get_embedded_metadata_cb (const gchar *preupdate,
/* Wait until there are no pending extraction requests
* before starting failsafe extraction process.
*/
- if (!priv->extraction_queue &&
- priv->failed_extraction_queue) {
- extractor_process_failsafe (miner);
- }
+ extractor_check_process_failsafe (miner);
}
static SendAndSpliceData *
@@ -2524,7 +2546,7 @@ process_file_cb (GObject *object,
file = G_FILE (object);
sparql = data->sparql;
file_info = g_file_query_info_finish (file, result, &error);
- priv = data->miner->private;
+ priv = TRACKER_MINER_FILES (data->miner)->private;
if (error) {
/* Something bad happened, notify about the error */
@@ -2598,8 +2620,6 @@ process_file_cb (GObject *object,
miner_files_add_to_datasource (data->miner, file, sparql);
if (!is_directory) {
- priv->extraction_queue = g_list_prepend (priv->extraction_queue, data);
-
/* Next step, if NOT a directory, get embedded metadata */
extractor_get_embedded_metadata (data, uri, mime_type);
} else {
@@ -2607,6 +2627,9 @@ process_file_cb (GObject *object,
g_debug ("Avoiding embedded metadata request for directory '%s'", uri);
sparql_builder_finish (data, NULL, NULL);
tracker_miner_fs_file_notify (TRACKER_MINER_FS (data->miner), data->file, NULL);
+
+ priv->extraction_queue = g_list_remove (priv->extraction_queue, data);
+ extractor_check_process_failsafe (data->miner);
}
g_object_unref (file_info);
@@ -2619,6 +2642,7 @@ miner_files_process_file (TrackerMinerFS *fs,
TrackerSparqlBuilder *sparql,
GCancellable *cancellable)
{
+ TrackerMinerFilesPrivate *priv;
ProcessFileData *data;
const gchar *attrs;
@@ -2628,6 +2652,9 @@ miner_files_process_file (TrackerMinerFS *fs,
data->sparql = g_object_ref (sparql);
data->file = g_object_ref (file);
+ priv = TRACKER_MINER_FILES (fs)->private;
+ priv->extraction_queue = g_list_prepend (priv->extraction_queue, data);
+
attrs = G_FILE_ATTRIBUTE_STANDARD_TYPE ","
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME ","
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]