[tracker/wip/carlosg/domain-ontologies: 29/93] tracker-store: Move handling of TRACKER_DB_ONTOLOGIES_DIR envvar here



commit 325ed5427be25356713a57b59b71cc1bfa9e0a9e
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Jun 4 16:41:37 2017 +0200

    tracker-store: Move handling of TRACKER_DB_ONTOLOGIES_DIR envvar here
    
    It does not make sense at the libtracker-data level, still might make some
    here.

 src/libtracker-data/tracker-data-manager.c |   35 +++++++++++----------------
 src/tracker-store/tracker-main.vala        |    4 +++
 2 files changed, 18 insertions(+), 21 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index ca77c7b..d1c8494 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -3742,7 +3742,6 @@ tracker_data_manager_init (TrackerDBManagerFlags   flags,
        TrackerDBStatement *stmt;
        GHashTable *ontos_table;
        GList *sorted = NULL, *l;
-       const gchar *env_path;
        gint max_id = 0;
        gboolean read_only;
        GHashTable *uri_id_map = NULL;
@@ -3869,33 +3868,27 @@ tracker_data_manager_init (TrackerDBManagerFlags   flags,
        }
 #endif /* DISABLE_JOURNAL */
 
-       env_path = g_getenv ("TRACKER_DB_ONTOLOGIES_DIR");
-
        g_set_object (&cache_location_stored, cache_location);
        g_set_object (&ontology_location_stored, ontology_location);
        g_set_object (&data_location_stored, data_location);
 
-       if (G_LIKELY (!env_path)) {
-               ontologies_dir = g_object_ref (ontology_location);
+       ontologies_dir = g_object_ref (ontology_location);
 
-               if (g_file_query_file_type (ontologies_dir, G_FILE_QUERY_INFO_NONE, NULL) != 
G_FILE_TYPE_DIRECTORY) {
-                       gchar *uri;
+       if (g_file_query_file_type (ontologies_dir, G_FILE_QUERY_INFO_NONE, NULL) != G_FILE_TYPE_DIRECTORY) {
+               gchar *uri;
 
-                       uri = g_file_get_uri (ontologies_dir);
-                       g_set_error (error, TRACKER_DATA_ONTOLOGY_ERROR,
-                                    TRACKER_DATA_ONTOLOGY_NOT_FOUND,
-                                    "'%s' is not a ontology location", uri);
-                       g_free (uri);
-                       tracker_db_manager_shutdown ();
-                       tracker_ontologies_shutdown ();
-                       if (!reloading) {
-                               tracker_locale_shutdown ();
-                       }
-                       tracker_data_update_shutdown ();
-                       return FALSE;
+               uri = g_file_get_uri (ontologies_dir);
+               g_set_error (error, TRACKER_DATA_ONTOLOGY_ERROR,
+                            TRACKER_DATA_ONTOLOGY_NOT_FOUND,
+                            "'%s' is not a ontology location", uri);
+               g_free (uri);
+               tracker_db_manager_shutdown ();
+               tracker_ontologies_shutdown ();
+               if (!reloading) {
+                       tracker_locale_shutdown ();
                }
-       } else {
-               ontologies_dir = g_file_new_for_path (env_path);
+               tracker_data_update_shutdown ();
+               return FALSE;
        }
 
 #ifndef DISABLE_JOURNAL
diff --git a/src/tracker-store/tracker-main.vala b/src/tracker-store/tracker-main.vala
index f39b2f2..de2f907 100644
--- a/src/tracker-store/tracker-main.vala
+++ b/src/tracker-store/tracker-main.vala
@@ -355,6 +355,10 @@ License which can be viewed at:
                                File.new_for_path (ontology_location.replace ("%HOME%", 
Environment.get_home_dir()).replace("%SHAREDIR%", SHAREDIR)) :
                                File.new_for_path (Path.build_filename (SHAREDIR, "tracker", "ontologies", 
"nepomuk"));
 
+                       var env_ontology = Environment.get_variable ("TRACKER_DB_ONTOLOGIES_DIR");
+                       if (env_ontology != null && env_ontology != "")
+                               final_ontology_location = File.new_for_path (env_ontology);
+
                        Tracker.Data.Manager.init (flags,
                                                   final_cache_location,
                                                   final_data_location,


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