[tracker/wip/carlosg/domain-ontologies: 86/93] tracker-store: Use TrackerDomainOntology helper
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/domain-ontologies: 86/93] tracker-store: Use TrackerDomainOntology helper
- Date: Mon, 19 Jun 2017 23:07:26 +0000 (UTC)
commit 347aec610e95c3178de1ca4ae61d76a2e8c81cb9
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Jun 19 15:39:09 2017 +0200
tracker-store: Use TrackerDomainOntology helper
src/libtracker-common/tracker-domain-ontology.c | 2 -
src/tracker-store/tracker-main.vala | 88 ++++++-----------------
2 files changed, 21 insertions(+), 69 deletions(-)
---
diff --git a/src/libtracker-common/tracker-domain-ontology.c b/src/libtracker-common/tracker-domain-ontology.c
index 07b4401..5f7c22e 100644
--- a/src/libtracker-common/tracker-domain-ontology.c
+++ b/src/libtracker-common/tracker-domain-ontology.c
@@ -37,10 +37,8 @@ struct {
{ "XDG_DOWNLOAD_DIR", G_USER_DIRECTORY_DOWNLOAD },
{ "XDG_MUSIC_DIR", G_USER_DIRECTORY_MUSIC },
{ "XDG_PICTURES_DIR", G_USER_DIRECTORY_PICTURES },
- { "XDG_PICTURES_DIR", G_USER_DIRECTORY_PICTURES },
{ "XDG_PUBLICSHARE_DIR", G_USER_DIRECTORY_PUBLIC_SHARE },
{ "XDG_VIDEOS_DIR", G_USER_DIRECTORY_VIDEOS },
- { "XDG_VIDEOS_DIR", G_USER_DIRECTORY_VIDEOS },
};
#define DOMAIN_ONTOLOGY_SECTION "DomainOntology"
diff --git a/src/tracker-store/tracker-main.vala b/src/tracker-store/tracker-main.vala
index 41a94dc..000415a 100644
--- a/src/tracker-store/tracker-main.vala
+++ b/src/tracker-store/tracker-main.vala
@@ -47,9 +47,9 @@ License which can be viewed at:
static bool force_reindex;
static bool readonly_mode;
static string domain_ontology;
- static string cache_location;
- static string data_location;
- static string ontology_location;
+ static File cache_location;
+ static File data_location;
+ static File ontology_location;
static string domain;
static string ontology_name;
@@ -82,11 +82,11 @@ License which can be viewed at:
message (" Ontology name.......................... %s", ontology_name);
if (cache_location != null)
- message (" Cache location......................... %s", cache_location);
+ message (" Cache location......................... %s", cache_location.get_uri());
if (data_location != null)
- message (" Data location.......................... %s", data_location);
+ message (" Data location.......................... %s", data_location.get_uri());
if (ontology_location != null)
- message (" Ontology location...................... %s", ontology_location);
+ message (" Ontology location...................... %s",
ontology_location.get_uri());
}
static void do_shutdown () {
@@ -226,52 +226,20 @@ License which can be viewed at:
message ("Using log file:'%s'", log_filename);
}
- if (domain_ontology != null) {
- string keyfile_path = Path.build_filename (SHAREDIR,
- "tracker",
- "domain-ontologies",
- domain_ontology+".rule");
- try {
- KeyFile keyfile = new KeyFile ( );
- keyfile.load_from_file (keyfile_path, GLib.KeyFileFlags.NONE);
-
- try {
- string? loaded_data_location = keyfile.get_string ("DomainOntology",
"DataLocation");
- if (data_location == null)
- data_location = loaded_data_location;
- } catch (KeyFileError m) {}
-
- try {
- string? loaded_cache_location = keyfile.get_string ("DomainOntology",
"CacheLocation");
- if (cache_location == null)
- cache_location = loaded_cache_location;
- } catch (KeyFileError m) {}
-
- try {
- string? loaded_ontology_location = keyfile.get_string
("DomainOntology", "OntologyLocation");
- if (ontology_location == null)
- ontology_location = loaded_ontology_location;
- } catch (KeyFileError m) {}
-
- try {
- string? loaded_domain = keyfile.get_string ("DomainOntology",
"Domain");
- if (domain == null)
- domain = loaded_domain;
- } catch (KeyFileError m) {}
-
- try {
- string? loaded_ontology_name = keyfile.get_string ("DomainOntology",
"OntologyName");
- if (ontology_name == null)
- ontology_name = loaded_ontology_name;
- } catch (KeyFileError m) {}
-
- } catch (KeyFileError ke) {
- critical("Loading " + keyfile_path + " " + ke.message);
- } catch (FileError fe) {
- critical("Loading " + keyfile_path + " " + fe.message);
- }
+ Tracker.DomainOntology domain_ontology_config;
+
+ try {
+ domain_ontology_config = new Tracker.DomainOntology (domain_ontology, null);
+ } catch (Error e) {
+ critical ("Could not load domain ontology definition '%s': %s", domain_ontology,
e.message);
+ return -1;
}
+ cache_location = domain_ontology_config.get_cache ();
+ data_location = domain_ontology_config.get_journal ();
+ ontology_location = domain_ontology_config.get_ontology ();
+ domain = domain_ontology_config.get_domain ();
+
sanity_check_option_values (config);
if (!Tracker.DBus.init (config)) {
@@ -335,24 +303,10 @@ License which can be viewed at:
}
try {
- File final_cache_location = cache_location != null ?
- File.new_for_path (cache_location.replace ("%HOME%",
Environment.get_home_dir()).replace("%SHAREDIR%", SHAREDIR)) :
- File.new_for_path (Path.build_filename (Environment.get_user_cache_dir (),
"tracker"));
- File final_data_location = data_location != null ?
- File.new_for_path (data_location.replace ("%HOME%",
Environment.get_home_dir()).replace("%SHAREDIR%", SHAREDIR)) :
- File.new_for_path (Path.build_filename (Environment.get_user_data_dir (),
"tracker", "data"));
- File final_ontology_location = ontology_location != null ?
- 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);
-
data_manager = new Tracker.Data.Manager (flags,
- final_cache_location,
- final_data_location,
- final_ontology_location,
+ cache_location,
+ data_location,
+ ontology_location,
true,
false,
select_cache_size,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]