[gnome-documents] miner: simplify cleanup_job_do_cleanup
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] miner: simplify cleanup_job_do_cleanup
- Date: Mon, 4 Jun 2012 19:22:21 +0000 (UTC)
commit 3d8c2a80a63e782506cea393459ee029f6071e4d
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 | 62 +++++++++------------------------------------
1 files changed, 13 insertions(+), 49 deletions(-)
---
diff --git a/src/miner/gd-zpj-miner.c b/src/miner/gd-zpj-miner.c
index 22c404d..8854c13 100644
--- a/src/miner/gd-zpj-miner.c
+++ b/src/miner/gd-zpj-miner.c
@@ -556,80 +556,44 @@ static void
cleanup_job_do_cleanup (CleanupJob *job)
{
GdZpjMiner *self = job->self;
- GString *select, *update;
- gboolean append_union = FALSE;
GList *l;
- TrackerSparqlCursor *cursor;
+ GString *update;
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)
{
+ 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;
+ g_string_append_printf (update,
+ "DELETE {"
+ " ?u a rdfs:Resource"
+ "} WHERE {"
+ " GRAPH <%s> {"
+ " ?u a rdfs:Resource"
+ " }"
+ "}",
+ resource);
}
- /* 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;
+ g_error_free (error);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]