tracker r1557 - in branches/indexer-split: . src/tracker-indexer
- From: carlosg svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1557 - in branches/indexer-split: . src/tracker-indexer
- Date: Mon, 2 Jun 2008 12:43:19 +0000 (UTC)
Author: carlosg
Date: Mon Jun 2 12:43:19 2008
New Revision: 1557
URL: http://svn.gnome.org/viewvc/tracker?rev=1557&view=rev
Log:
2008-06-02 Carlos Garnacho <carlos imendio com>
* src/tracker-indexer/tracker-indexer-db.c (load_sql_file): Moved from
trackerd, executes the queries contained in a text file.
(tracker_indexer_db_get_file_metadata): Load sql files necessary to
create the tables/triggers if the DB file didn't exist.
* src/tracker-indexer/tracker-indexer.c (init_indexer): Create the
DB directory if it didn't exist or was deleted.
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/src/tracker-indexer/tracker-indexer-db.c
branches/indexer-split/src/tracker-indexer/tracker-indexer.c
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer-db.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer-db.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer-db.c Mon Jun 2 12:43:19 2008
@@ -762,6 +762,39 @@
}
}
+static void
+load_sql_file (TrackerDBInterface *iface,
+ const gchar *file,
+ const gchar *delimiter)
+{
+ gchar *path, *content, **queries;
+ gint i;
+
+ path = tracker_db_manager_get_sql_file (file);
+
+ if (!delimiter) {
+ delimiter = ";";
+ }
+
+ if (!g_file_get_contents (path, &content, NULL, NULL)) {
+ g_critical ("Cannot read SQL file:'%s', please reinstall tracker"
+ " or check read permissions on the file if it exists", file);
+ g_assert_not_reached ();
+ }
+
+ queries = g_strsplit (content, delimiter, -1);
+
+ for (i = 0; queries[i]; i++) {
+ tracker_db_interface_execute_query (iface, NULL, queries[i]);
+ }
+
+ g_message ("Loaded SQL file:'%s'", file);
+
+ g_strfreev (queries);
+ g_free (content);
+ g_free (path);
+}
+
TrackerDBInterface *
tracker_indexer_db_get_common (void)
{
@@ -786,8 +819,14 @@
{
TrackerDBInterface *interface;
const gchar *path;
+ gboolean create = FALSE;
path = tracker_db_manager_get_file (TRACKER_DB_FILE_META);
+
+ if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
+ create = TRUE;
+ }
+
interface = tracker_db_interface_sqlite_new (path);
tracker_db_interface_set_procedure_table (interface, prepared_queries);
@@ -796,5 +835,11 @@
tracker_db_manager_get_page_size (TRACKER_DB_FILE_META),
tracker_db_manager_get_add_functions (TRACKER_DB_FILE_META));
+ if (create) {
+ load_sql_file (interface, "sqlite-service.sql", NULL);
+ load_sql_file (interface, "sqlite-service-triggers.sql", "!");
+ load_sql_file (interface, "sqlite-metadata.sql", NULL);
+ }
+
return interface;
}
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer.c Mon Jun 2 12:43:19 2008
@@ -263,6 +263,10 @@
tracker_dir_remove (priv->db_dir);
}
+ if (!g_file_test (priv->db_dir, G_FILE_TEST_EXISTS)) {
+ g_mkdir_with_parents (priv->db_dir, 00755);
+ }
+
index_file = g_build_filename (priv->db_dir, "file-index.db", NULL);
priv->index = tracker_index_new (index_file,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]