[tracker/wip/carlosg/domain-ontologies: 11/93] Add cache location to db manager and data manager
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/domain-ontologies: 11/93] Add cache location to db manager and data manager
- Date: Mon, 19 Jun 2017 23:01:08 +0000 (UTC)
commit ae2dc43297ad64589f13b928ee95d1cac7ca02f4
Author: Philip Van Hoof <philip codeminded be>
Date: Sun Jan 29 16:14:03 2017 +0100
Add cache location to db manager and data manager
src/libtracker-data/libtracker-data.vapi | 4 +-
src/libtracker-data/tracker-data-backup.c | 5 ++-
src/libtracker-data/tracker-data-backup.h | 1 +
src/libtracker-data/tracker-data-manager.c | 37 +++++++++++++------
src/libtracker-data/tracker-data-manager.h | 1 +
src/libtracker-data/tracker-db-manager.c | 18 ++++++---
src/libtracker-data/tracker-db-manager.h | 5 ++-
src/libtracker-direct/tracker-direct.vala | 6 ++--
src/tracker-store/tracker-backup.vala | 4 +-
src/tracker-store/tracker-main.vala | 2 +-
src/tracker/tracker-reset.c | 2 +-
src/tracker/tracker-sql.c | 2 +-
tests/libtracker-data/tracker-backup-test.c | 6 ++--
.../libtracker-data/tracker-ontology-change-test.c | 4 +-
tests/libtracker-data/tracker-ontology-test.c | 6 ++--
tests/libtracker-data/tracker-sparql-blank-test.c | 2 +-
tests/libtracker-data/tracker-sparql-test.c | 2 +-
tests/libtracker-fts/tracker-fts-test.c | 2 +-
18 files changed, 67 insertions(+), 42 deletions(-)
---
diff --git a/src/libtracker-data/libtracker-data.vapi b/src/libtracker-data/libtracker-data.vapi
index 4d2cf57..930e1af 100644
--- a/src/libtracker-data/libtracker-data.vapi
+++ b/src/libtracker-data/libtracker-data.vapi
@@ -224,12 +224,12 @@ namespace Tracker {
public delegate void BackupFinished (GLib.Error error);
public void backup_save (GLib.File destination, owned BackupFinished callback);
- public void backup_restore (GLib.File journal, string? domain, string? ontology_name, [CCode
(array_length = false)] string[]? test_schema, BusyCallback busy_callback) throws GLib.Error;
+ public void backup_restore (GLib.File journal, string? loc, string? domain, string?
ontology_name, [CCode (array_length = false)] string[]? test_schema, BusyCallback busy_callback) throws
GLib.Error;
}
[CCode (cheader_filename = "libtracker-data/tracker-data-manager.h")]
namespace Data.Manager {
- public bool init (DBManagerFlags flags, string? domain, string? ontology_name, [CCode
(array_length = false)] string[]? test_schema, out bool first_time, bool journal_check, bool
restoring_backup, uint select_cache_size, uint update_cache_size, BusyCallback? busy_callback, string?
busy_status) throws DBInterfaceError, DBJournalError;
+ public bool init (DBManagerFlags flags, string? loc, string? domain, string? ontology_name,
[CCode (array_length = false)] string[]? test_schema, out bool first_time, bool journal_check, bool
restoring_backup, uint select_cache_size, uint update_cache_size, BusyCallback? busy_callback, string?
busy_status) throws DBInterfaceError, DBJournalError;
public void shutdown ();
}
diff --git a/src/libtracker-data/tracker-data-backup.c b/src/libtracker-data/tracker-data-backup.c
index fef3582..dc4a5b5 100644
--- a/src/libtracker-data/tracker-data-backup.c
+++ b/src/libtracker-data/tracker-data-backup.c
@@ -555,6 +555,7 @@ tracker_data_backup_save (GFile *destination,
void
tracker_data_backup_restore (GFile *journal,
+ const gchar *loc,
const gchar *domain,
const gchar *ontology_name,
const gchar **test_schemas,
@@ -655,7 +656,7 @@ tracker_data_backup_restore (GFile *journal,
&info->error);
#endif /* DISABLE_JOURNAL */
- tracker_db_manager_init_locations (domain, ontology_name);
+ tracker_db_manager_init_locations (loc, domain, ontology_name);
/* Re-set the DB version file, so that its mtime changes. The mtime of this
* file will change only when the whole DB is recreated (after a hard reset
@@ -696,7 +697,7 @@ tracker_data_backup_restore (GFile *journal,
}
#endif /* DISABLE_JOURNAL */
- tracker_data_manager_init (flags, domain, ontology_name, test_schemas,
+ tracker_data_manager_init (flags, loc, domain, ontology_name, test_schemas,
&is_first, TRUE, TRUE,
select_cache_size, update_cache_size,
busy_callback, busy_user_data,
diff --git a/src/libtracker-data/tracker-data-backup.h b/src/libtracker-data/tracker-data-backup.h
index 3d05573..e3060e6 100644
--- a/src/libtracker-data/tracker-data-backup.h
+++ b/src/libtracker-data/tracker-data-backup.h
@@ -48,6 +48,7 @@ void tracker_data_backup_save (GFile *destination,
gpointer user_data,
GDestroyNotify destroy);
void tracker_data_backup_restore (GFile *journal,
+ const gchar *loc,
const gchar *domain,
const gchar *ontology_name,
const gchar **test_schema,
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index bcd81dd..0de3cb4 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -68,6 +68,7 @@
static gchar *ontologies_dir;
static gchar *ontology_name_stored;
static gchar *loc_stored;
+static gchar *domain_stored;
static gboolean initialized;
static gboolean reloading = FALSE;
#ifndef DISABLE_JOURNAL
@@ -3533,7 +3534,7 @@ tracker_data_manager_reload (TrackerBusyCallback busy_callback,
/* And initialize it again, this actually triggers index recreation. */
status = tracker_data_manager_init (flags,
- loc_stored, ontology_name_stored,
+ loc_stored, domain_stored, ontology_name_stored,
NULL,
&is_first,
TRUE,
@@ -3675,6 +3676,7 @@ tracker_data_manager_init_fts (TrackerDBInterface *iface,
gboolean
tracker_data_manager_init (TrackerDBManagerFlags flags,
const gchar *loc,
+ const gchar *domain,
const gchar *ontology_name,
const gchar **test_schemas,
gboolean *first_time,
@@ -3734,7 +3736,7 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
#endif
if (!tracker_db_manager_init (flags,
- loc, ontology_name,
+ loc, domain, ontology_name,
&is_first_time_index,
restoring_backup,
FALSE,
@@ -3805,22 +3807,33 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
env_path = g_getenv ("TRACKER_DB_ONTOLOGIES_DIR");
g_free (loc_stored);
- loc_stored = g_strdup(loc);
+
+ if (loc != NULL)
+ loc_stored = g_strdup(loc);
+ else
+ loc_stored = NULL;
+
g_free (ontology_name_stored);
- ontology_name_stored = g_strdup(ontology_name);
+
+ if (ontology_name != NULL)
+ ontology_name_stored = g_strdup(ontology_name);
+ else
+ ontology_name = NULL;
+
+ if (domain == NULL)
+ domain = "tracker";
+ g_free (domain_stored);
+ domain_stored = g_strdup(domain);
if (G_LIKELY (!env_path)) {
if (ontology_name == NULL) {
ontologies_dir = g_build_filename (SHAREDIR,
- "tracker",
+ domain,
"ontologies",
NULL);
} else {
- if (loc == NULL) {
- loc = "tracker";
- }
ontologies_dir = g_build_filename (SHAREDIR,
- loc,
+ domain,
"ontologies",
ontology_name,
NULL);
@@ -4285,7 +4298,7 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
tracker_data_manager_shutdown ();
return tracker_data_manager_init (flags |
TRACKER_DB_MANAGER_DO_NOT_CHECK_ONTOLOGY,
- loc, ontology_name,
+ loc, domain, ontology_name,
test_schemas,
first_time,
journal_check,
@@ -4376,7 +4389,7 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
tracker_data_manager_shutdown ();
return tracker_data_manager_init (flags |
TRACKER_DB_MANAGER_DO_NOT_CHECK_ONTOLOGY,
- loc, ontology_name,
+ loc, domain, ontology_name,
test_schemas,
first_time,
journal_check,
@@ -4484,7 +4497,7 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
tracker_data_manager_shutdown ();
return tracker_data_manager_init (flags |
TRACKER_DB_MANAGER_DO_NOT_CHECK_ONTOLOGY,
- loc, ontology_name,
+ loc, domain, ontology_name,
test_schemas,
first_time,
journal_check,
diff --git a/src/libtracker-data/tracker-data-manager.h b/src/libtracker-data/tracker-data-manager.h
index 39f05eb..5d0958c 100644
--- a/src/libtracker-data/tracker-data-manager.h
+++ b/src/libtracker-data/tracker-data-manager.h
@@ -47,6 +47,7 @@ typedef enum {
GQuark tracker_data_ontology_error_quark (void);
gboolean tracker_data_manager_init (TrackerDBManagerFlags flags,
const gchar *loc,
+ const gchar *domain,
const gchar *ontology_name,
const gchar **test_schema,
gboolean *first_time,
diff --git a/src/libtracker-data/tracker-db-manager.c b/src/libtracker-data/tracker-db-manager.c
index feb5e7e..c73f667 100644
--- a/src/libtracker-data/tracker-db-manager.c
+++ b/src/libtracker-data/tracker-db-manager.c
@@ -157,6 +157,7 @@ static gchar *data_dir = NULL;
static gchar *user_data_dir = NULL;
static gchar *in_use_filename = NULL;
static gchar *in_use_loc = NULL;
+static gchar *in_use_domain = NULL;
static gchar *in_use_ontology_name = NULL;
static gpointer db_type_enum_class_pointer;
static TrackerDBManagerFlags old_flags = 0;
@@ -665,7 +666,7 @@ tracker_db_manager_locale_changed (GError **error)
* to check for locale mismatches for initializing the database.
*/
if (!locations_initialized) {
- tracker_db_manager_init_locations (in_use_loc, in_use_ontology_name);
+ tracker_db_manager_init_locations (in_use_loc, in_use_domain, in_use_ontology_name);
}
/* Get current collation locale */
@@ -794,7 +795,7 @@ db_recreate_all (GError **error)
}
void
-tracker_db_manager_init_locations (const char *loc, const char *ontology_name)
+tracker_db_manager_init_locations (const char *loc, const gchar *domain, const char *ontology_name)
{
const gchar *dir;
guint i;
@@ -867,6 +868,7 @@ perform_recreate (gboolean *first_time, GError **error)
static gboolean
db_manager_init_unlocked (TrackerDBManagerFlags flags,
const gchar *loc,
+ const gchar *domain,
const gchar *ontology_name,
gboolean *first_time,
gboolean restoring_backup,
@@ -917,20 +919,23 @@ db_manager_init_unlocked (TrackerDBManagerFlags flags,
g_free (in_use_filename);
g_free (in_use_loc);
+ g_free (in_use_domain);
g_free (in_use_ontology_name);
if (loc == NULL)
loc = "tracker";
in_use_loc = g_strdup (loc);
+ if (domain == NULL)
+ domain = "tracker";
+ in_use_domain = g_strdup (domain);
+
if (ontology_name == NULL)
in_use_ontology_name = NULL;
else
in_use_ontology_name = g_strdup (ontology_name);
- in_use_loc = g_strdup (loc);
-
- tracker_db_manager_init_locations (loc, ontology_name);
+ tracker_db_manager_init_locations (loc, domain, ontology_name);
if (ontology_name == NULL) {
in_use_filename = g_build_filename (g_get_user_data_dir (),
loc,
@@ -1290,6 +1295,7 @@ db_manager_init_unlocked (TrackerDBManagerFlags flags,
gboolean
tracker_db_manager_init (TrackerDBManagerFlags flags,
const gchar *loc,
+ const gchar *domain,
const gchar *ontology_name,
gboolean *first_time,
gboolean restoring_backup,
@@ -1305,7 +1311,7 @@ tracker_db_manager_init (TrackerDBManagerFlags flags,
g_mutex_lock (&init_mutex);
- retval = db_manager_init_unlocked (flags, loc, ontology_name,
+ retval = db_manager_init_unlocked (flags, loc, domain, ontology_name,
first_time, restoring_backup,
shared_cache,
select_cache_size, update_cache_size,
diff --git a/src/libtracker-data/tracker-db-manager.h b/src/libtracker-data/tracker-db-manager.h
index 5848fe2..1df3e1c 100644
--- a/src/libtracker-data/tracker-db-manager.h
+++ b/src/libtracker-data/tracker-db-manager.h
@@ -54,6 +54,7 @@ typedef enum {
GType tracker_db_get_type (void) G_GNUC_CONST;
gboolean tracker_db_manager_init (TrackerDBManagerFlags flags,
const gchar *loc,
+ const gchar *domain,
const gchar *ontology_name,
gboolean *first_time,
gboolean restoring_backup,
@@ -69,7 +70,9 @@ void tracker_db_manager_remove_all (gboolean
void tracker_db_manager_optimize (void);
const gchar * tracker_db_manager_get_file (TrackerDB db);
TrackerDBInterface *tracker_db_manager_get_db_interface (void);
-void tracker_db_manager_init_locations (const gchar *loc, const gchar *ontology_name);
+void tracker_db_manager_init_locations (const gchar *loc,
+ const gchar *domain,
+ const gchar *ontology_name);
gboolean tracker_db_manager_has_enough_space (void);
void tracker_db_manager_create_version_file (void);
void tracker_db_manager_remove_version_file (void);
diff --git a/src/libtracker-direct/tracker-direct.vala b/src/libtracker-direct/tracker-direct.vala
index f978586..256f295 100644
--- a/src/libtracker-direct/tracker-direct.vala
+++ b/src/libtracker-direct/tracker-direct.vala
@@ -38,7 +38,7 @@ public class Tracker.Direct.Connection : Tracker.Sparql.Connection {
}
Data.Manager.init (DBManagerFlags.READONLY | DBManagerFlags.ENABLE_MUTEXES,
- null /* domain */ , null /* ontology */,
+ null /*loc */, null /* domain */ , null /* ontology */,
null, null, false, false, select_cache_size, 0, null,
null);
}
@@ -49,7 +49,7 @@ public class Tracker.Direct.Connection : Tracker.Sparql.Connection {
}
}
- public Connection.custom_ontology (string domain, string ontology_name) throws Sparql.Error,
IOError, DBusError {
+ public Connection.custom_ontology (string? loc, string? domain, string? ontology_name) throws
Sparql.Error, IOError, DBusError {
try {
if (use_count == 0) {
// make sure that current locale vs db locale are the same,
@@ -65,7 +65,7 @@ public class Tracker.Direct.Connection : Tracker.Sparql.Connection {
}
Data.Manager.init (DBManagerFlags.READONLY | DBManagerFlags.ENABLE_MUTEXES,
- domain, ontology_name,
+ loc, domain, ontology_name,
null, null, false, false, select_cache_size, 0, null,
null);
}
diff --git a/src/tracker-store/tracker-backup.vala b/src/tracker-store/tracker-backup.vala
index 77a812f..ee6a4f8 100644
--- a/src/tracker-store/tracker-backup.vala
+++ b/src/tracker-store/tracker-backup.vala
@@ -84,8 +84,8 @@ public class Tracker.Backup : Object {
var notifier = (Status) (Tracker.DBus.get_object (typeof (Status)));
var busy_callback = notifier.get_callback ();
- // TODO: set domain and ontology_name here from store session
- Data.backup_restore (journal, null, null, null, busy_callback);
+ // TODO: set loc, domain and ontology_name here from store session
+ Data.backup_restore (journal, null, null, null, null, busy_callback);
request.end ();
} catch (Error e) {
diff --git a/src/tracker-store/tracker-main.vala b/src/tracker-store/tracker-main.vala
index d0cac10..95fd705 100644
--- a/src/tracker-store/tracker-main.vala
+++ b/src/tracker-store/tracker-main.vala
@@ -325,7 +325,7 @@ License which can be viewed at:
bool is_first_time_index;
try {
- Tracker.Data.Manager.init (flags, cache_location, ontology_name,
+ Tracker.Data.Manager.init (flags, cache_location, domain, ontology_name,
null,
out is_first_time_index,
true,
diff --git a/src/tracker/tracker-reset.c b/src/tracker/tracker-reset.c
index ba525a2..29185c4 100644
--- a/src/tracker/tracker-reset.c
+++ b/src/tracker/tracker-reset.c
@@ -292,7 +292,7 @@ reset_run (void)
/* Clean up (select_cache_size and update_cache_size don't matter here) */
if (!tracker_db_manager_init (TRACKER_DB_MANAGER_REMOVE_ALL,
- NULL, NULL, /* domain and ontology-name */
+ NULL, NULL, NULL, /* locl, domain and ontology-name */
NULL,
FALSE,
FALSE,
diff --git a/src/tracker/tracker-sql.c b/src/tracker/tracker-sql.c
index 2616ce4..a9ef3e1 100644
--- a/src/tracker/tracker-sql.c
+++ b/src/tracker/tracker-sql.c
@@ -97,7 +97,7 @@ sql_by_query (void)
gboolean first_time = FALSE;
gint n_rows = 0;
- if (!tracker_data_manager_init (0, NULL, NULL,
+ if (!tracker_data_manager_init (0, NULL, NULL, NULL,
NULL,
&first_time,
FALSE,
diff --git a/tests/libtracker-data/tracker-backup-test.c b/tests/libtracker-data/tracker-backup-test.c
index d09b064..310754d 100644
--- a/tests/libtracker-data/tracker-backup-test.c
+++ b/tests/libtracker-data/tracker-backup-test.c
@@ -124,7 +124,7 @@ test_backup_and_restore_helper (gboolean journal)
tracker_db_journal_set_rotating (FALSE, G_MAXSIZE, NULL);
tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
- NULL, NULL,
+ NULL, NULL, NULL,
(const gchar **) test_schemas,
NULL, FALSE, FALSE,
100, 100, NULL, NULL, NULL, &error);
@@ -189,7 +189,7 @@ test_backup_and_restore_helper (gboolean journal)
#endif /* DISABLE_JOURNAL */
tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
- NULL, NULL,
+ NULL, NULL, NULL,
(const gchar **) test_schemas,
NULL, FALSE, FALSE,
100, 100, NULL, NULL, NULL, &error);
@@ -198,7 +198,7 @@ test_backup_and_restore_helper (gboolean journal)
check_content_in_db (0, 0);
- tracker_data_backup_restore (backup_file, NULL, NULL,(const gchar **) test_schemas, NULL, NULL,
&error);
+ tracker_data_backup_restore (backup_file, NULL, NULL, NULL,(const gchar **) test_schemas, NULL, NULL,
&error);
g_assert_no_error (error);
check_content_in_db (3, 1);
diff --git a/tests/libtracker-data/tracker-ontology-change-test.c
b/tests/libtracker-data/tracker-ontology-change-test.c
index 806c18f..8261695 100644
--- a/tests/libtracker-data/tracker-ontology-change-test.c
+++ b/tests/libtracker-data/tracker-ontology-change-test.c
@@ -228,7 +228,7 @@ test_ontology_change (void)
g_assert_no_error (error);
g_chmod (ontology_file, 0666);
- tracker_data_manager_init (0, NULL, NULL, (const gchar **) test_schemas,
+ tracker_data_manager_init (0, NULL, NULL, NULL, (const gchar **) test_schemas,
NULL, FALSE, FALSE,
100, 100, NULL, NULL, NULL, &error);
@@ -272,7 +272,7 @@ test_ontology_change (void)
delete_db (FALSE);
- tracker_data_manager_init (0, NULL, NULL, (const gchar **) test_schemas,
+ tracker_data_manager_init (0, NULL, NULL, NULL, (const gchar **) test_schemas,
NULL, TRUE, FALSE,
100, 100, NULL, NULL, NULL, &error);
diff --git a/tests/libtracker-data/tracker-ontology-test.c b/tests/libtracker-data/tracker-ontology-test.c
index 1abc3f8..4ad2956 100644
--- a/tests/libtracker-data/tracker-ontology-test.c
+++ b/tests/libtracker-data/tracker-ontology-test.c
@@ -187,7 +187,7 @@ test_ontology_init (TestInfo *test_info,
/* first-time initialization */
tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
- NULL, NULL,
+ NULL, NULL, NULL,
NULL,
NULL,
FALSE,
@@ -207,7 +207,7 @@ test_ontology_init (TestInfo *test_info,
/* initialization from existing database */
tracker_data_manager_init (0,
- NULL, NULL,
+ NULL, NULL, NULL,
NULL,
NULL,
FALSE,
@@ -243,7 +243,7 @@ test_query (TestInfo *test_info,
/* initialization */
tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
- NULL, NULL, /* domain and ontology_name */
+ NULL, NULL, NULL, /* loc, domain and ontology_name */
NULL,
NULL,
FALSE,
diff --git a/tests/libtracker-data/tracker-sparql-blank-test.c
b/tests/libtracker-data/tracker-sparql-blank-test.c
index 69f3ba4..88f959f 100644
--- a/tests/libtracker-data/tracker-sparql-blank-test.c
+++ b/tests/libtracker-data/tracker-sparql-blank-test.c
@@ -56,7 +56,7 @@ test_blank (TestInfo *info,
/* initialization */
tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
- NULL, NULL, /* domain and ontology_name */
+ NULL, NULL, NULL, /* loc, domain and ontology_name */
NULL,
NULL,
FALSE,
diff --git a/tests/libtracker-data/tracker-sparql-test.c b/tests/libtracker-data/tracker-sparql-test.c
index 0f87985..1647635 100644
--- a/tests/libtracker-data/tracker-sparql-test.c
+++ b/tests/libtracker-data/tracker-sparql-test.c
@@ -268,7 +268,7 @@ test_sparql_query (TestInfo *test_info,
tracker_db_journal_set_rotating (FALSE, G_MAXSIZE, NULL);
tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
- NULL, NULL, /* domain and ontology_name */
+ NULL, NULL, NULL, /* loc, domain and ontology_name */
test_schemas,
NULL, FALSE, FALSE,
100, 100, NULL, NULL, NULL, &error);
diff --git a/tests/libtracker-fts/tracker-fts-test.c b/tests/libtracker-fts/tracker-fts-test.c
index f9ca792..da15fad 100644
--- a/tests/libtracker-fts/tracker-fts-test.c
+++ b/tests/libtracker-fts/tracker-fts-test.c
@@ -69,7 +69,7 @@ test_sparql_query (gconstpointer test_data)
test_schemas[0] = data_prefix;
tracker_db_journal_set_rotating (FALSE, G_MAXSIZE, NULL);
tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
- NULL, NULL,
+ NULL, NULL, NULL,
test_schemas,
NULL, FALSE, FALSE,
100, 100, NULL, NULL, NULL, &error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]