[gnome-documents/wip/skydrive] miner: Simplify cleanup_job_do_cleanup
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/wip/skydrive] miner: Simplify cleanup_job_do_cleanup
- Date: Thu, 24 May 2012 21:11:30 +0000 (UTC)
commit 7a5b54163e910a5ffc06150e26fde69ab451c811
Author: Debarshi Ray <debarshir gnome org>
Date: Thu May 24 22:54:32 2012 +0200
miner: Simplify cleanup_job_do_cleanup
When an account has been removed just delete the whole graph.
Fixes: https://bugzilla.gnome.org/666535
src/miner/gd-zpj-miner.c | 87 ++++++++++++---------------------------------
1 files changed, 23 insertions(+), 64 deletions(-)
---
diff --git a/src/miner/gd-zpj-miner.c b/src/miner/gd-zpj-miner.c
index 46eef12..c7b6eb9 100644
--- a/src/miner/gd-zpj-miner.c
+++ b/src/miner/gd-zpj-miner.c
@@ -556,80 +556,39 @@ static void
cleanup_job_do_cleanup (CleanupJob *job)
{
GdZpjMiner *self = job->self;
- GString *select, *update;
- gboolean append_union = FALSE;
GList *l;
- TrackerSparqlCursor *cursor;
- GError *error = NULL;
- const gchar *resource;
if (job->old_datasources == NULL)
return;
- update = g_string_new (NULL);
- g_string_append (update, "DELETE { ");
-
- /* select all documents from the datasources we want to remove */
- select = g_string_new (NULL);
- g_string_append (select, "SELECT ?urn WHERE { ");
-
for (l = job->old_datasources; l != NULL; l = l->next)
{
+ GError *error = NULL;
+ gchar *update;
+ const gchar *resource;
+
resource = l->data;
g_debug ("Cleaning up old datasource %s", resource);
- if (append_union)
- g_string_append (select, " UNION ");
- else
- append_union = TRUE;
-
- g_string_append_printf (select, "{ ?urn nie:dataSource \"%s\" }", resource);
-
- /* also append the datasource itself to the list of resources to delete */
- g_string_append_printf (update, "<%s> a rdfs:Resource . ", resource);
- }
-
- g_string_append (select, " }");
-
- cursor = tracker_sparql_connection_query (self->priv->connection,
- select->str,
- self->priv->cancellable,
- &error);
-
- g_string_free (select, TRUE);
-
- if (error != NULL)
- {
- g_printerr ("Error while cleaning up old accounts: %s\n", error->message);
- return;
- }
-
- /* gather all the documents we want to remove */
- while (tracker_sparql_cursor_next (cursor, self->priv->cancellable, NULL))
- {
- resource = tracker_sparql_cursor_get_string (cursor, 0, NULL);
- g_debug ("Cleaning up resource %s belonging to an old datasource", resource);
-
- if (resource != NULL)
- g_string_append_printf (update, "<%s> a rdfs:Resource . ", resource);
- }
-
- g_string_append (update, " }");
- g_object_unref (cursor);
-
- /* actually remove everything we have to remove */
- tracker_sparql_connection_update (self->priv->connection,
- update->str,
- G_PRIORITY_DEFAULT,
- self->priv->cancellable,
- &error);
-
- g_string_free (update, TRUE);
-
- if (error != NULL)
- {
- g_printerr ("Error while cleaning up old accounts: %s\n", error->message);
- return;
+ update = g_strdup_printf ("DELETE FROM <%s> {"
+ " ?u a rdfs:Resource"
+ "} WHERE {"
+ " ?u a rdfs:Resource"
+ "}",
+ resource);
+
+ tracker_sparql_connection_update (self->priv->connection,
+ update,
+ G_PRIORITY_DEFAULT,
+ self->priv->cancellable,
+ &error);
+ g_free (update);
+
+ if (error != NULL)
+ {
+ g_printerr ("Error while cleaning up old accounts: %s\n", error->message);
+ g_error_free (error);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]