[tracker] miners: Request DBus name after creating miner objects



commit 34253e00866fc20cac5ca205ce07f9dfa26dd4a1
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Jul 5 23:42:35 2017 +0200

    miners: Request DBus name after creating miner objects
    
    Fixes those not seeming to autostart properly through the
    "tracker daemon -s" CLI command, because it calls for a method
    in an object that's not yet created at the time the DBus name
    is visible.

 src/miners/apps/tracker-main.c     |   25 +++++++++++++------------
 src/miners/fs/tracker-main.c       |   25 +++++++++++++------------
 src/miners/rss/tracker-main.c      |   24 ++++++++++++------------
 src/tracker-extract/tracker-main.c |   25 +++++++++++++------------
 4 files changed, 51 insertions(+), 48 deletions(-)
---
diff --git a/src/miners/apps/tracker-main.c b/src/miners/apps/tracker-main.c
index f78d797..8f0a556 100644
--- a/src/miners/apps/tracker-main.c
+++ b/src/miners/apps/tracker-main.c
@@ -237,18 +237,6 @@ main (gint argc, gchar *argv[])
                return EXIT_FAILURE;
        }
 
-       dbus_name = tracker_domain_ontology_get_domain (domain_ontology, DBUS_NAME_SUFFIX);
-
-       if (!tracker_dbus_request_name (connection, dbus_name, &error)) {
-               g_critical ("Could not request DBus name '%s': %s",
-                           dbus_name, error->message);
-               g_error_free (error);
-               g_free (dbus_name);
-               return EXIT_FAILURE;
-       }
-
-       g_free (dbus_name);
-
        tracker_log_init (verbosity, &log_filename);
        if (log_filename) {
                g_message ("Using log file:'%s'", log_filename);
@@ -293,6 +281,19 @@ main (gint argc, gchar *argv[])
                          G_CALLBACK (miner_finished_cb),
                          NULL);
 
+       /* Request DBus name */
+       dbus_name = tracker_domain_ontology_get_domain (domain_ontology, DBUS_NAME_SUFFIX);
+
+       if (!tracker_dbus_request_name (connection, dbus_name, &error)) {
+               g_critical ("Could not request DBus name '%s': %s",
+                           dbus_name, error->message);
+               g_error_free (error);
+               g_free (dbus_name);
+               return EXIT_FAILURE;
+       }
+
+       g_free (dbus_name);
+
        initialize_signal_handler ();
 
        /* Go, go, go! */
diff --git a/src/miners/fs/tracker-main.c b/src/miners/fs/tracker-main.c
index 28dfa5b..db03868 100644
--- a/src/miners/fs/tracker-main.c
+++ b/src/miners/fs/tracker-main.c
@@ -754,18 +754,6 @@ main (gint argc, gchar *argv[])
                return EXIT_FAILURE;
        }
 
-       dbus_name = tracker_domain_ontology_get_domain (domain_ontology, DBUS_NAME_SUFFIX);
-
-       if (!tracker_dbus_request_name (connection, dbus_name, &error)) {
-               g_critical ("Could not request DBus name '%s': %s",
-                           dbus_name, error->message);
-               g_error_free (error);
-               g_free (dbus_name);
-               return EXIT_FAILURE;
-       }
-
-       g_free (dbus_name);
-
        /* Initialize logging */
        config = tracker_config_new ();
 
@@ -847,6 +835,19 @@ main (gint argc, gchar *argv[])
                return EXIT_FAILURE;
        }
 
+       /* Request DBus name */
+       dbus_name = tracker_domain_ontology_get_domain (domain_ontology, DBUS_NAME_SUFFIX);
+
+       if (!tracker_dbus_request_name (connection, dbus_name, &error)) {
+               g_critical ("Could not request DBus name '%s': %s",
+                           dbus_name, error->message);
+               g_error_free (error);
+               g_free (dbus_name);
+               return EXIT_FAILURE;
+       }
+
+       g_free (dbus_name);
+
        /* Check if we should crawl and if we should force mtime
         * checking based on the config.
         */
diff --git a/src/miners/rss/tracker-main.c b/src/miners/rss/tracker-main.c
index ac6b9e1..850ed03 100644
--- a/src/miners/rss/tracker-main.c
+++ b/src/miners/rss/tracker-main.c
@@ -188,18 +188,6 @@ main (int argc, char **argv)
                return EXIT_FAILURE;
        }
 
-       dbus_name = tracker_domain_ontology_get_domain (domain_ontology, DBUS_NAME_SUFFIX);
-
-       if (!tracker_dbus_request_name (connection, dbus_name, &error)) {
-               g_critical ("Could not request DBus name '%s': %s",
-                           dbus_name, error->message);
-               g_error_free (error);
-               g_free (dbus_name);
-               return EXIT_FAILURE;
-       }
-
-       g_free (dbus_name);
-
        miner = tracker_miner_rss_new (&error);
        if (!miner) {
                g_critical ("Could not create new RSS miner: '%s', exiting...\n",
@@ -215,6 +203,18 @@ main (int argc, char **argv)
                return EXIT_FAILURE;
        }
 
+       dbus_name = tracker_domain_ontology_get_domain (domain_ontology, DBUS_NAME_SUFFIX);
+
+       if (!tracker_dbus_request_name (connection, dbus_name, &error)) {
+               g_critical ("Could not request DBus name '%s': %s",
+                           dbus_name, error->message);
+               g_error_free (error);
+               g_free (dbus_name);
+               return EXIT_FAILURE;
+       }
+
+       g_free (dbus_name);
+
        loop = g_main_loop_new (NULL, FALSE);
 
        if (domain_ontology && domain_ontology_name) {
diff --git a/src/tracker-extract/tracker-main.c b/src/tracker-extract/tracker-main.c
index a46859a..284c619 100644
--- a/src/tracker-extract/tracker-main.c
+++ b/src/tracker-extract/tracker-main.c
@@ -378,18 +378,6 @@ main (int argc, char *argv[])
                return EXIT_FAILURE;
        }
 
-       dbus_name = tracker_domain_ontology_get_domain (domain_ontology, DBUS_NAME_SUFFIX);
-
-       if (!tracker_dbus_request_name (connection, dbus_name, &error)) {
-               g_critical ("Could not request DBus name '%s': %s",
-                           dbus_name, error->message);
-               g_error_free (error);
-               g_free (dbus_name);
-               return EXIT_FAILURE;
-       }
-
-       g_free (dbus_name);
-
        config = tracker_config_new ();
 
        /* Extractor command line arguments */
@@ -455,6 +443,19 @@ main (int argc, char *argv[])
        controller = tracker_extract_controller_new (decorator, connection);
        tracker_miner_start (TRACKER_MINER (decorator));
 
+       /* Request DBus name */
+       dbus_name = tracker_domain_ontology_get_domain (domain_ontology, DBUS_NAME_SUFFIX);
+
+       if (!tracker_dbus_request_name (connection, dbus_name, &error)) {
+               g_critical ("Could not request DBus name '%s': %s",
+                           dbus_name, error->message);
+               g_error_free (error);
+               g_free (dbus_name);
+               return EXIT_FAILURE;
+       }
+
+       g_free (dbus_name);
+
        /* Main loop */
        main_loop = g_main_loop_new (NULL, FALSE);
 


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