[tracker/anonymous-file-nodes: 13/27] The second query wasn't needed, squashme



commit 85fcc954e7041f9ff46657bb952b0fba26f07759
Author: Philip Van Hoof <philip codeminded be>
Date:   Wed Jan 27 18:01:51 2010 +0100

    The second query wasn't needed, squashme

 src/tracker-writeback/tracker-writeback-consumer.c |   96 ++++----------------
 1 files changed, 19 insertions(+), 77 deletions(-)
---
diff --git a/src/tracker-writeback/tracker-writeback-consumer.c b/src/tracker-writeback/tracker-writeback-consumer.c
index 03c1b17..977c694 100644
--- a/src/tracker-writeback/tracker-writeback-consumer.c
+++ b/src/tracker-writeback/tracker-writeback-consumer.c
@@ -50,13 +50,6 @@ typedef struct {
 	guint state;
 } TrackerWritebackConsumerPrivate;
 
-typedef struct {
-	TrackerWritebackConsumerPrivate *priv;
-	TrackerWritebackConsumer *consumer;
-	QueryData *data;
-} ContData;
-
-
 enum {
 	STATE_IDLE,
 	STATE_PROCESSING
@@ -164,29 +157,17 @@ sparql_rdf_types_match (const gchar * const *module_types,
 }
 
 static void
-end_consumer (TrackerWritebackConsumer *consumer, 
-              QueryData *data)
-{
-	TrackerWritebackConsumerPrivate *priv;
-
-	priv = TRACKER_WRITEBACK_CONSUMER_GET_PRIVATE (consumer);
-
-	g_free (data->subject);
-	g_strfreev (data->rdf_types);
-	g_slice_free (QueryData, data);
-
-	priv->idle_id = g_idle_add (process_queue_cb, consumer);
-}
-
-static void
 sparql_query_cb (GPtrArray *result,
                  GError    *error,
                  gpointer   user_data)
 {
-	ContData *cont_data = user_data;
-	TrackerWritebackConsumerPrivate *priv = cont_data->priv;
-	TrackerWritebackConsumer *consumer = cont_data->consumer;
-	QueryData *data = cont_data->data;
+	TrackerWritebackConsumerPrivate *priv;
+	TrackerWritebackConsumer *consumer;
+	QueryData *data;
+
+	consumer = TRACKER_WRITEBACK_CONSUMER (user_data);
+	priv = TRACKER_WRITEBACK_CONSUMER_GET_PRIVATE (consumer);
+	data = g_queue_pop_head (priv->process_queue);
 
 	if (!error && result && result->len > 0) {
 		GHashTableIter iter;
@@ -220,52 +201,11 @@ sparql_query_cb (GPtrArray *result,
 		g_message ("  No files qualify for updates");
 	}
 
-	end_consumer (consumer, data);
-
-	g_object_unref (cont_data->consumer);
-	g_slice_free (ContData, cont_data);
-}
-
-static void
-get_url_cb (GPtrArray *result,
-            GError    *error,
-            gpointer   user_data)
-{
-	TrackerWritebackConsumerPrivate *priv;
-	TrackerWritebackConsumer *consumer;
-	QueryData *data;
-
-	consumer = TRACKER_WRITEBACK_CONSUMER (user_data);
-	priv = TRACKER_WRITEBACK_CONSUMER_GET_PRIVATE (consumer);
-	data = g_queue_pop_head (priv->process_queue);
-
-	if (!error && result && result->len > 0) {
-		GStrv row = g_ptr_array_index (result, 0);
-
-		if (row && row[0]) {
-			const gchar *url = row[0];
-			gchar *query;
-			ContData *cont_data = g_slice_new (ContData);
-
-			cont_data->priv = priv;
-			cont_data->consumer = g_object_ref (consumer);
-			cont_data->data = data;
-
-			query = g_strdup_printf ("SELECT '%s' '%s' ?predicate ?object {"
-			                         "  <%s> ?predicate ?object ."
-			                         "  ?predicate tracker:writeback true "
-			                         "}", url, data->subject, data->subject);
-
-			tracker_resources_sparql_query_async (priv->client,
-			                                      query,
-			                                      sparql_query_cb,
-			                                      cont_data);
+	g_free (data->subject);
+	g_strfreev (data->rdf_types);
+	g_slice_free (QueryData, data);
 
-			g_free (query);
-		}
-	} else {
-		end_consumer (consumer, data);
-	}
+	priv->idle_id = g_idle_add (process_queue_cb, consumer);
 }
 
 static gboolean
@@ -290,13 +230,15 @@ process_queue_cb (gpointer user_data)
 	/* We use IE = DO, so we can optimize using nie:isStoredAs instead of
 	 * nie:url here. Please change this when we change that decision. */
 
-	query = g_strdup_printf ("SELECT ?url { <%s> nie:url ?url }",
-	                         data->subject);
+		query = g_strdup_printf ("SELECT ?url '%s' ?predicate ?object {"
+		                         "  <%s> ?predicate ?object ; nie:url ?url ."
+		                         "  ?predicate tracker:writeback true "
+		                         "}", data->subject, data->subject);
 
-	tracker_resources_sparql_query_async (priv->client,
-	                                      query,
-	                                      get_url_cb,
-	                                      consumer);
+		tracker_resources_sparql_query_async (priv->client,
+		                                      query,
+		                                      sparql_query_cb,
+		                                      consumer);
 
 	g_free (query);
 



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