[tracker/wip/carlosg/data-update-cleanups: 8/11] tracker: Allow in-memory endpoints through the CLI command



commit c6b42fab0acea7c7d2201f334577cbf83c1f5f31
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Apr 25 17:11:32 2020 +0200

    tracker: Allow in-memory endpoints through the CLI command
    
    If no database path is passed, create an in-memory database.

 src/tracker/tracker-endpoint.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/src/tracker/tracker-endpoint.c b/src/tracker/tracker-endpoint.c
index c36df7b24..c546ef603 100644
--- a/src/tracker/tracker-endpoint.c
+++ b/src/tracker/tracker-endpoint.c
@@ -82,11 +82,6 @@ typedef enum _TrackerEndpointError {
 static gboolean
 sanity_check (void)
 {
-       if (!database_path) {
-               g_printerr ("%s\n", _("No database path was provided"));
-               return FALSE;
-       }
-
        if (!!ontology_path == !!ontology_name) {
                /* TRANSLATORS: those are commandline arguments */
                g_printerr ("%s\n", _("One “ontology” or “ontology-path” option should be provided"));
@@ -198,7 +193,7 @@ tracker_endpoint (int argc, const char **argv)
        TrackerSparqlConnection *connection;
        GOptionContext *context;
        GError *error = NULL;
-       GFile *database, *ontology = NULL;
+       GFile *database = NULL, *ontology = NULL;
 
        context = g_option_context_new (NULL);
        g_option_context_add_main_entries (context, entries, NULL);
@@ -222,7 +217,9 @@ tracker_endpoint (int argc, const char **argv)
                return EXIT_FAILURE;
        }
 
-       database = g_file_new_for_commandline_arg (database_path);
+       if (database_path)
+               database = g_file_new_for_commandline_arg (database_path);
+
        if (ontology_path) {
                ontology = g_file_new_for_commandline_arg (ontology_path);
        } else if (ontology_name) {
@@ -232,8 +229,14 @@ tracker_endpoint (int argc, const char **argv)
        }
 
        g_assert (ontology != NULL);
-       g_print (_("Opening database at %s…"), database_path);
-       g_print ("\n");
+
+       if (database_path) {
+               g_print (_("Opening database at %s…"), database_path);
+               g_print ("\n");
+       } else {
+               g_print (_("Creating in-memory database"));
+               g_print ("\n");
+       }
 
        connection = tracker_sparql_connection_new (0, database, ontology, NULL, &error);
        if (!connection) {


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