[tracker/extraction-improvements: 4/5] tracker-miner-fs: ensure the sparql is correctly closed on all success situations
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/extraction-improvements: 4/5] tracker-miner-fs: ensure the sparql is correctly closed on all success situations
- Date: Fri, 6 May 2011 13:10:35 +0000 (UTC)
commit e8c507b39246d1043c70032b396c610f8a2fe0e4
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed May 4 15:56:05 2011 +0200
tracker-miner-fs: ensure the sparql is correctly closed on all success situations
src/miners/fs/tracker-miner-files.c | 118 +++++++++++++++++++----------------
1 files changed, 65 insertions(+), 53 deletions(-)
---
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index b857d13..cc342e6 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -1908,62 +1908,13 @@ process_file_data_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;
- 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);
-
- 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);
-
if (sparql && *sparql) {
gboolean is_iri;
const gchar *urn;
@@ -2033,6 +1984,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);
@@ -2143,6 +2154,7 @@ process_file_cb (GObject *object,
/* Otherwise, don't request embedded metadata extraction.
* We setup an idle so that we keep the previous behavior. */
g_debug ("Avoiding embedded metadata request for uri '%s'", uri);
+ sparql_builder_finish (data, NULL, NULL, NULL);
tracker_miner_fs_file_notify (TRACKER_MINER_FS (data->miner), data->file, NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]