[tracker/wip/carlosg/tracker-3.0-api-breaks: 24/56] libtracker-data: Allow NULL ontologies on readonly connections
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/tracker-3.0-api-breaks: 24/56] libtracker-data: Allow NULL ontologies on readonly connections
- Date: Tue, 14 Jan 2020 17:40:55 +0000 (UTC)
commit aa2c438cbff4d7d58186e1dac463780001fcb2a3
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Dec 21 11:35:39 2019 +0100
libtracker-data: Allow NULL ontologies on readonly connections
We have the ability to fetch the ontology from gvdb data, or by
introspecting the database itself. Doing so will allow opening
Tracker databases without further knowledge of how they are set up.
src/libtracker-data/tracker-data-manager.c | 12 +++++++++---
src/libtracker-direct/tracker-direct.c | 8 +++++---
src/libtracker-sparql/tracker-connection.vala | 5 ++++-
3 files changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index d5a1b0c6d..7a71922c7 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -3919,8 +3919,13 @@ tracker_data_manager_new (TrackerDBManagerFlags flags,
{
TrackerDataManager *manager;
- if (!cache_location || !ontology_location) {
- g_warning ("All data storage and ontology locations must be provided");
+ if (!cache_location) {
+ g_warning ("Data storage location must be provided");
+ return NULL;
+ }
+
+ if ((flags & TRACKER_DB_MANAGER_READONLY) == 0 && !ontology_location) {
+ g_warning ("Ontology location must be provided");
return NULL;
}
@@ -4215,7 +4220,8 @@ tracker_data_manager_initable_init (GInitable *initable,
return FALSE;
}
- if (g_file_query_file_type (manager->ontology_location, G_FILE_QUERY_INFO_NONE, NULL) !=
G_FILE_TYPE_DIRECTORY) {
+ if (manager->ontology_location &&
+ g_file_query_file_type (manager->ontology_location, G_FILE_QUERY_INFO_NONE, NULL) !=
G_FILE_TYPE_DIRECTORY) {
gchar *uri;
uri = g_file_get_uri (manager->ontology_location);
diff --git a/src/libtracker-direct/tracker-direct.c b/src/libtracker-direct/tracker-direct.c
index d357503dd..9bf4dad86 100644
--- a/src/libtracker-direct/tracker-direct.c
+++ b/src/libtracker-direct/tracker-direct.c
@@ -223,12 +223,14 @@ tracker_direct_connection_initable_init (GInitable *initable,
return FALSE;
/* Init data manager */
- if (priv->flags & TRACKER_SPARQL_CONNECTION_FLAGS_READONLY)
+ if (priv->flags & TRACKER_SPARQL_CONNECTION_FLAGS_READONLY) {
db_flags |= TRACKER_DB_MANAGER_READONLY;
-
- if (!priv->ontology) {
+ } else if (!priv->ontology) {
gchar *filename;
+ /* If the connection is read/write, and no ontology is specified,
+ * we use the Nepomuk one.
+ */
filename = g_build_filename (SHAREDIR, "tracker", "ontologies",
"nepomuk", NULL);
priv->ontology = g_file_new_for_path (filename);
diff --git a/src/libtracker-sparql/tracker-connection.vala b/src/libtracker-sparql/tracker-connection.vala
index 6ba930d43..285d69829 100644
--- a/src/libtracker-sparql/tracker-connection.vala
+++ b/src/libtracker-sparql/tracker-connection.vala
@@ -172,7 +172,10 @@ public abstract class Tracker.Sparql.Connection : Object {
*
* The caller is entirely free to define an ontology or reuse Nepomuk for
* its purposes. For the former see the "Defining ontologies" section in
- * this library docs. For the latter pass a %NULL @ontology.
+ * this library documentation. For the latter pass a %NULL @ontology.
+ *
+ * If the connection is readonly the @ontology argument will be ignored,
+ * and the ontology reconstructed from the database itself.
*
* The @ontology argument may be a resource:/// URI, a directory location
* must be provided, all children .ontology and .description files will
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]