Commit b9876d4e authored by Carlos Garnacho's avatar Carlos Garnacho

libtracker-data: Remove test_schemas argument from TrackerDataManager

This is superfluous now that we can load ontologies from custom places.
parent a6f701b9
......@@ -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? cache_location, string? data_location, GLib.File? ontology_location, [CCode (array_length = false)] string[]? test_schema, BusyCallback busy_callback) throws GLib.Error;
public void backup_restore (GLib.File journal, string? cache_location, string? data_location, GLib.File? ontology_location, BusyCallback busy_callback) throws GLib.Error;
}
[CCode (cheader_filename = "libtracker-data/tracker-data-manager.h")]
namespace Data.Manager {
public bool init (DBManagerFlags flags, string? cache_location, string? data_location, GLib.File? ontology_location, [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? cache_location, string? data_location, GLib.File? ontology_location, 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 ();
}
......
......@@ -586,7 +586,6 @@ tracker_data_backup_restore (GFile *journal,
const gchar *cache_location,
const gchar *data_location,
GFile *ontology_location,
const gchar **test_schemas,
TrackerBusyCallback busy_callback,
gpointer busy_user_data,
GError **error)
......@@ -725,7 +724,7 @@ tracker_data_backup_restore (GFile *journal,
}
#endif /* DISABLE_JOURNAL */
tracker_data_manager_init (flags, cache_location, data_location, ontology_location, test_schemas,
tracker_data_manager_init (flags, cache_location, data_location, ontology_location,
&is_first, TRUE, TRUE,
select_cache_size, update_cache_size,
busy_callback, busy_user_data,
......@@ -739,7 +738,7 @@ tracker_data_backup_restore (GFile *journal,
cache_location,
data_location,
ontology_location,
test_schemas, &is_first, TRUE, TRUE,
&is_first, TRUE, TRUE,
select_cache_size, update_cache_size,
busy_callback, busy_user_data,
"Restoring backup", &internal_error);
......
......@@ -51,7 +51,6 @@ void tracker_data_backup_restore (GFile *journal,
const gchar *cache_location,
const gchar *data_location,
GFile *ontology_location,
const gchar **test_schema,
TrackerBusyCallback busy_callback,
gpointer busy_user_data,
GError **error);
......
......@@ -3574,7 +3574,6 @@ tracker_data_manager_reload (TrackerBusyCallback busy_callback,
cache_location_stored,
data_location_stored,
ontology_location_stored,
NULL,
&is_first,
TRUE,
FALSE,
......@@ -3727,7 +3726,6 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
const gchar *cache_location,
const gchar *data_location,
GFile *ontology_location,
const gchar **test_schemas,
gboolean *first_time,
gboolean journal_check,
gboolean restoring_backup,
......@@ -3997,35 +3995,6 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
g_free (uri);
}
if (test_schemas) {
guint p;
for (p = 0; test_schemas[p] != NULL; p++) {
GError *ontology_error = NULL;
gchar *test_schema_path;
GFile *file;
test_schema_path = g_strconcat (test_schemas[p], ".ontology", NULL);
file = g_file_new_for_path (test_schema_path);
g_debug ("Loading ontology:'%s' (TEST ONTOLOGY)", test_schema_path);
load_ontology_file (file,
&max_id,
FALSE,
NULL,
NULL,
uri_id_map,
&ontology_error);
if (ontology_error) {
g_error ("Error loading ontology (%s): %s",
test_schema_path,
ontology_error->message);
}
g_free (test_schema_path);
g_object_unref (file);
}
}
tracker_data_begin_ontology_transaction (&internal_error);
if (internal_error) {
g_propagate_error (error, internal_error);
......@@ -4098,20 +4067,6 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
import_ontology_file (l->data, FALSE, !journal_check);
}
if (test_schemas) {
guint p;
for (p = 0; test_schemas[p] != NULL; p++) {
gchar *test_schema_path;
GFile *file;
test_schema_path = g_strconcat (test_schemas[p], ".ontology", NULL);
file = g_file_new_for_path (test_schema_path);
import_ontology_file (file, FALSE, TRUE);
g_free (test_schema_path);
g_object_unref (file);
}
}
tracker_data_commit_transaction (&internal_error);
if (internal_error) {
g_propagate_error (error, internal_error);
......@@ -4214,14 +4169,6 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
return FALSE;
}
if (test_schemas) {
for (p = 0; test_schemas[p] != NULL; p++) {
gchar *test_schema_path;
test_schema_path = g_strconcat (test_schemas[p], ".ontology", NULL);
ontos = g_list_append (ontos, test_schema_path);
}
}
/* check ontology against database */
/* Get a map of tracker:Ontology v. nao:lastModified so that we can test
......@@ -4373,7 +4320,6 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
cache_location,
data_location,
ontology_location,
test_schemas,
first_time,
journal_check,
restoring_backup,
......@@ -4467,7 +4413,6 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
cache_location,
data_location,
ontology_location,
test_schemas,
first_time,
journal_check,
restoring_backup,
......@@ -4576,7 +4521,6 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
cache_location,
data_location,
ontology_location,
test_schemas,
first_time,
journal_check,
restoring_backup,
......
......@@ -50,7 +50,6 @@ gboolean tracker_data_manager_init (TrackerDBManagerFlags fl
const gchar *cache_location,
const gchar *data_location,
GFile *ontology_location,
const gchar **test_schema,
gboolean *first_time,
gboolean journal_check,
gboolean restoring_backup,
......
......@@ -39,7 +39,7 @@ public class Tracker.Direct.Connection : Tracker.Sparql.Connection {
Data.Manager.init (DBManagerFlags.READONLY | DBManagerFlags.ENABLE_MUTEXES,
null /*loc */, null /* domain */ , null /* ontology */,
null, null, false, false, select_cache_size, 0, null, null);
null, false, false, select_cache_size, 0, null, null);
}
use_count++;
......@@ -66,7 +66,7 @@ public class Tracker.Direct.Connection : Tracker.Sparql.Connection {
Data.Manager.init (DBManagerFlags.READONLY | DBManagerFlags.ENABLE_MUTEXES,
loc, domain, ontology_loc,
null, null, false, false, select_cache_size, 0, null, null);
null, false, false, select_cache_size, 0, null, null);
}
use_count++;
......
......@@ -85,7 +85,7 @@ public class Tracker.Backup : Object {
var busy_callback = notifier.get_callback ();
// TODO: set cache_location, data_location and ontology_location here from store session
Data.backup_restore (journal, null, null, null, null, busy_callback);
Data.backup_restore (journal, null, null, null, busy_callback);
request.end ();
} catch (Error e) {
......
......@@ -353,7 +353,6 @@ License which can be viewed at:
final_cache_location,
final_data_location,
final_ontology_location,
null,
out is_first_time_index,
true,
false,
......
......@@ -98,7 +98,6 @@ sql_by_query (void)
gint n_rows = 0;
if (!tracker_data_manager_init (0, NULL, NULL, NULL,
NULL,
&first_time,
FALSE,
FALSE,
......
......@@ -103,29 +103,25 @@ check_content_in_db (gint expected_instances,
static void
test_backup_and_restore_helper (gboolean journal)
{
gchar *data_prefix, *data_filename, *backup_location, *backup_filename, *db_location, *meta_db;
gchar *data_prefix, *data_filename, *backup_location, *backup_filename, *db_location, *meta_db, *ontologies;
GError *error = NULL;
GFile *backup_file;
gchar *test_schemas[5] = { NULL, NULL, NULL, NULL, NULL };
GFile *test_schemas;
db_location = g_build_path (G_DIR_SEPARATOR_S, xdg_location, "tracker", NULL);
data_prefix = g_build_path (G_DIR_SEPARATOR_S,
TOP_SRCDIR, "tests", "libtracker-data", "backup", "backup",
NULL);
/*
* This function uses $(data_prefix).ontology
*/
test_schemas[0] = g_build_path (G_DIR_SEPARATOR_S, TOP_SRCDIR, "tests", "libtracker-data", "ontologies", "20-dc", NULL);
test_schemas[1] = g_build_path (G_DIR_SEPARATOR_S, TOP_SRCDIR, "tests", "libtracker-data", "ontologies", "31-nao", NULL);
test_schemas[2] = g_build_path (G_DIR_SEPARATOR_S, TOP_SRCDIR, "tests", "libtracker-data", "ontologies", "90-tracker", NULL);
test_schemas[3] = data_prefix;
ontologies = g_build_path (G_DIR_SEPARATOR_S,
TOP_SRCDIR, "tests", "libtracker-data", "backup",
NULL);
test_schemas = g_file_new_for_path (ontologies);
tracker_db_journal_set_rotating (FALSE, G_MAXSIZE, NULL);
tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
NULL, NULL, NULL,
(const gchar **) test_schemas,
NULL, NULL, test_schemas,
NULL, FALSE, FALSE,
100, 100, NULL, NULL, NULL, &error);
......@@ -191,8 +187,7 @@ test_backup_and_restore_helper (gboolean journal)
#endif /* DISABLE_JOURNAL */
tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
NULL, NULL, NULL,
(const gchar **) test_schemas,
NULL, NULL, test_schemas,
NULL, FALSE, FALSE,
100, 100, NULL, NULL, NULL, &error);
......@@ -200,14 +195,12 @@ test_backup_and_restore_helper (gboolean journal)
check_content_in_db (0, 0);
tracker_data_backup_restore (backup_file, NULL, NULL, NULL,(const gchar **) test_schemas, NULL, NULL, &error);
tracker_data_backup_restore (backup_file, NULL, NULL, test_schemas, NULL, NULL, &error);
g_assert_no_error (error);
check_content_in_db (3, 1);
g_free (test_schemas[0]);
g_free (test_schemas[1]);
g_free (test_schemas[2]);
g_free (test_schemas[3]);
g_object_unref (test_schemas);
g_free (ontologies);
g_assert_cmpint (backup_calls, ==, 1);
......@@ -250,7 +243,6 @@ setup (TestInfo *info,
g_assert_true (g_setenv ("XDG_DATA_HOME", xdg_location, TRUE));
g_assert_true (g_setenv ("XDG_CACHE_HOME", xdg_location, TRUE));
g_assert_true (g_setenv ("TRACKER_DB_ONTOLOGIES_DIR", TOP_SRCDIR "/src/ontologies/", TRUE));
}
}
......
......@@ -182,21 +182,17 @@ test_ontology_change (void)
{
gchar *ontology_file;
GFile *file2;
gchar *prefix, *build_prefix;
gchar *prefix, *build_prefix, *ontologies;
gchar *ontology_dir;
guint i;
GError *error = NULL;
gchar *test_schemas[5] = { NULL, NULL, NULL, NULL, NULL };
GFile *test_schemas;
delete_db (TRUE);
prefix = g_build_path (G_DIR_SEPARATOR_S, TOP_SRCDIR, "tests", "libtracker-data", NULL);
build_prefix = g_build_path (G_DIR_SEPARATOR_S, TOP_BUILDDIR, "tests", "libtracker-data", NULL);
test_schemas[0] = g_build_path (G_DIR_SEPARATOR_S, prefix, "ontologies", "20-dc", NULL);
test_schemas[1] = g_build_path (G_DIR_SEPARATOR_S, prefix, "ontologies", "31-nao", NULL);
test_schemas[2] = g_build_path (G_DIR_SEPARATOR_S, prefix, "ontologies", "90-tracker", NULL);
test_schemas[3] = g_build_path (G_DIR_SEPARATOR_S, build_prefix, "change", "ontologies", "99-example", NULL);
ontologies = g_build_filename (prefix, "ontologies", NULL);
ontology_file = g_build_path (G_DIR_SEPARATOR_S, build_prefix, "change", "ontologies", "99-example.ontology", NULL);
......@@ -206,6 +202,7 @@ test_ontology_change (void)
ontology_dir = g_build_path (G_DIR_SEPARATOR_S, build_prefix, "change", "ontologies", NULL);
g_mkdir_with_parents (ontology_dir, 0777);
test_schemas = g_file_new_for_path (ontology_dir);
g_free (ontology_dir);
for (i = 0; changes[i].ontology; i++) {
......@@ -228,7 +225,7 @@ test_ontology_change (void)
g_assert_no_error (error);
g_chmod (ontology_file, 0666);
tracker_data_manager_init (0, NULL, NULL, NULL, (const gchar **) test_schemas,
tracker_data_manager_init (0, NULL, NULL, test_schemas,
NULL, FALSE, FALSE,
100, 100, NULL, NULL, NULL, &error);
......@@ -272,7 +269,7 @@ test_ontology_change (void)
delete_db (FALSE);
tracker_data_manager_init (0, NULL, NULL, NULL, (const gchar **) test_schemas,
tracker_data_manager_init (0, NULL, NULL, test_schemas,
NULL, TRUE, FALSE,
100, 100, NULL, NULL, NULL, &error);
......@@ -299,9 +296,8 @@ test_ontology_change (void)
g_file_delete (file2, NULL, NULL);
g_object_unref (file2);
g_free (test_schemas[0]);
g_free (test_schemas[1]);
g_free (test_schemas[2]);
g_object_unref (test_schemas);
g_free (ontologies);
g_free (build_prefix);
g_free (prefix);
}
......@@ -318,7 +314,6 @@ main (int argc, char **argv)
g_setenv ("XDG_DATA_HOME", data_dir, TRUE);
g_setenv ("XDG_CACHE_HOME", data_dir, TRUE);
g_setenv ("TRACKER_DB_ONTOLOGIES_DIR", TOP_SRCDIR "/src/ontologies/", TRUE);
/* add test cases */
......
......@@ -189,7 +189,6 @@ test_ontology_init (TestInfo *test_info,
tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
NULL, NULL, NULL,
NULL,
NULL,
FALSE,
FALSE,
100,
......@@ -209,7 +208,6 @@ test_ontology_init (TestInfo *test_info,
tracker_data_manager_init (0,
NULL, NULL, NULL,
NULL,
NULL,
FALSE,
FALSE,
100,
......@@ -246,7 +244,6 @@ test_query (TestInfo *test_info,
tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
NULL, NULL, NULL, /* loc, domain and ontology_name */
NULL,
NULL,
FALSE,
FALSE,
100,
......@@ -298,7 +295,6 @@ setup (TestInfo *info,
g_assert_true (g_setenv ("XDG_DATA_HOME", xdg_location, TRUE));
g_assert_true (g_setenv ("XDG_CACHE_HOME", xdg_location, TRUE));
g_assert_true (g_setenv ("TRACKER_DB_ONTOLOGIES_DIR", TOP_SRCDIR "/src/ontologies/", TRUE));
}
}
......
......@@ -58,7 +58,6 @@ test_blank (TestInfo *info,
tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
NULL, NULL, NULL, /* loc, domain and ontology_name */
NULL,
NULL,
FALSE,
FALSE,
100,
......@@ -148,7 +147,6 @@ setup (TestInfo *info,
g_assert_true (g_setenv ("XDG_DATA_HOME", xdg_location, TRUE));
g_assert_true (g_setenv ("XDG_CACHE_HOME", xdg_location, TRUE));
g_assert_true (g_setenv ("TRACKER_DB_ONTOLOGIES_DIR", TOP_SRCDIR "/src/ontologies/", TRUE));
}
}
......
......@@ -255,7 +255,7 @@ test_sparql_query (TestInfo *test_info,
gchar *query, *query_filename;
gchar *results_filename;
gchar *prefix, *data_prefix, *test_prefix;
const gchar *test_schemas[2] = { NULL, NULL };
GFile *file, *test_schemas;
/* initialization */
prefix = g_build_path (G_DIR_SEPARATOR_S, TOP_SRCDIR, "tests", "libtracker-data", NULL);
......@@ -263,13 +263,14 @@ test_sparql_query (TestInfo *test_info,
test_prefix = g_build_filename (prefix, test_info->test_name, NULL);
g_free (prefix);
test_schemas[0] = data_prefix;
file = g_file_new_for_path (data_prefix);
test_schemas = g_file_get_parent (file);
g_object_unref (file);
tracker_db_journal_set_rotating (FALSE, G_MAXSIZE, NULL);
tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
NULL, NULL, NULL, /* loc, domain and ontology_name */
test_schemas,
NULL, NULL, test_schemas, /* loc, domain and ontology_name */
NULL, FALSE, FALSE,
100, 100, NULL, NULL, NULL, &error);
......@@ -343,6 +344,7 @@ test_sparql_query (TestInfo *test_info,
g_free (query_filename);
g_free (query);
g_free (results_filename);
g_object_unref (test_schemas);
tracker_data_manager_shutdown ();
}
......@@ -370,7 +372,6 @@ setup (TestInfo *info,
g_assert_true (g_setenv ("XDG_DATA_HOME", xdg_location, TRUE));
g_assert_true (g_setenv ("XDG_CACHE_HOME", xdg_location, TRUE));
g_assert_true (g_setenv ("TRACKER_DB_ONTOLOGIES_DIR", TOP_SRCDIR "/src/ontologies/", TRUE));
}
}
......
......@@ -53,28 +53,27 @@ test_sparql_query (gconstpointer test_data)
gchar *update, *update_filename;
gchar *query, *query_filename;
gchar *results, *results_filename;
gchar *prefix, *data_prefix, *test_prefix;
gchar *prefix, *test_prefix;
GFile *ontology;
gint i;
const gchar *test_schemas[2] = { NULL, NULL };
error = NULL;
test_info = test_data;
/* initialization */
prefix = g_build_path (G_DIR_SEPARATOR_S, TOP_SRCDIR, "tests", "libtracker-fts", NULL);
data_prefix = g_build_filename (prefix, "data", NULL);
test_prefix = g_build_filename (prefix, test_info->test_name, NULL);
ontology = g_file_new_for_path (prefix);
g_free (prefix);
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,
test_schemas,
NULL, NULL, ontology,
NULL, FALSE, FALSE,
100, 100, NULL, NULL, NULL, &error);
g_assert_no_error (error);
g_object_unref (ontology);
/* load data / perform updates */
......@@ -163,7 +162,6 @@ test_sparql_query (gconstpointer test_data)
g_string_free (test_results, TRUE);
}
g_free (data_prefix);
g_free (test_prefix);
tracker_data_manager_shutdown ();
......@@ -183,7 +181,6 @@ main (int argc, char **argv)
g_setenv ("XDG_DATA_HOME", current_dir, TRUE);
g_setenv ("XDG_CACHE_HOME", current_dir, TRUE);
g_setenv ("TRACKER_DB_ONTOLOGIES_DIR", TOP_SRCDIR "/src/ontologies/", TRUE);
g_setenv ("TRACKER_FTS_STOP_WORDS", "0", TRUE);
g_free (current_dir);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment