[tracker/wip/carlosg/deserialize-api: 9/17] cli: Update tracker-import to use deserialization API
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/deserialize-api: 9/17] cli: Update tracker-import to use deserialization API
- Date: Thu, 30 Jun 2022 21:57:56 +0000 (UTC)
commit 14a7bff63ccf72b1c03291198bb2c89eba93ba66
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun May 8 00:08:50 2022 +0200
cli: Update tracker-import to use deserialization API
Exercise the new API in the import tool.
src/tracker/tracker-import.c | 37 +++++++++++++++++++++++++++++++++----
1 file changed, 33 insertions(+), 4 deletions(-)
---
diff --git a/src/tracker/tracker-import.c b/src/tracker/tracker-import.c
index 6d35fb1b4..30d7f913a 100644
--- a/src/tracker/tracker-import.c
+++ b/src/tracker/tracker-import.c
@@ -85,11 +85,31 @@ create_connection (GError **error)
}
}
+static void
+deserialize_cb (GObject *source,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GError *error = NULL;
+
+ if (!tracker_sparql_connection_deserialize_finish (TRACKER_SPARQL_CONNECTION (source),
+ res, &error)) {
+ g_printerr ("%s, %s\n",
+ _("Could not run import"),
+ error->message);
+ exit (EXIT_FAILURE);
+ }
+
+ g_main_loop_quit (user_data);
+}
+
static int
import_run (void)
{
g_autoptr(TrackerSparqlConnection) connection = NULL;
g_autoptr(GError) error = NULL;
+ g_autoptr(GMainLoop) main_loop = NULL;
+ g_autoptr(GInputStream) stream = NULL;
gchar **p;
connection = create_connection (&error);
@@ -101,17 +121,16 @@ import_run (void)
return EXIT_FAILURE;
}
+ main_loop = g_main_loop_new (NULL, FALSE);
+
for (p = filenames; *p; p++) {
g_autoptr(GFile) file = NULL;
g_autofree gchar *update = NULL;
g_autofree gchar *uri = NULL;
file = g_file_new_for_commandline_arg (*p);
- uri = g_file_get_uri (file);
- update = g_strdup_printf ("LOAD <%s>", uri);
-
- tracker_sparql_connection_update (connection, update, NULL, &error);
+ stream = G_INPUT_STREAM (g_file_read (file, NULL, &error));
if (error) {
g_printerr ("%s, %s\n",
_("Could not run import"),
@@ -119,6 +138,16 @@ import_run (void)
return EXIT_FAILURE;
}
+ tracker_sparql_connection_deserialize_async (connection,
+ TRACKER_DESERIALIZE_FLAGS_NONE,
+ TRACKER_RDF_FORMAT_TURTLE,
+ NULL,
+ stream,
+ NULL,
+ deserialize_cb,
+ main_loop);
+ g_main_loop_run (main_loop);
+
g_print ("Successfully imported %s", g_file_peek_path (file));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]