[tracker/checkpoint] libtracker-data, tracker-control: Add disabling the journal as compile feature
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/checkpoint] libtracker-data, tracker-control: Add disabling the journal as compile feature
- Date: Thu, 23 Jun 2011 12:38:54 +0000 (UTC)
commit d9ac4b10517c8d9478f332e1904a99a2d548ef02
Author: Philip Van Hoof <philip codeminded be>
Date: Thu Jun 23 14:36:54 2011 +0200
libtracker-data, tracker-control: Add disabling the journal as compile feature
configure.ac | 14 +++
src/libtracker-data/tracker-data-manager.c | 16 ++++
src/libtracker-data/tracker-data-update.c | 51 ++++++++++-
src/libtracker-data/tracker-db-journal.c | 121 ++++++++++++++++++++++++-
src/libtracker-data/tracker-db-manager.c | 43 ++++++++--
src/tracker-control/tracker-control-general.c | 14 +++-
6 files changed, 245 insertions(+), 14 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 1075147..d162fd7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -616,6 +616,20 @@ if test "x$enable_maemo" = "xyes" ; then
fi
####################################################################
+# Check if we should disable the journal
+####################################################################
+
+AC_ARG_ENABLE(journal,
+ AS_HELP_STRING([--enable-journal],
+ [enable journal [[default=yes]]]),
+ [enable_journal="$enableval"],
+ [enable_journal=yes])
+
+if test "x$enable_journal" = "xno" ; then
+ AC_DEFINE(DISABLE_JOURNAL, 1, [Define if we disable the journal])
+fi
+
+####################################################################
# Check for SQLite
####################################################################
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 3bdcd89..7762015 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -1747,6 +1747,7 @@ get_ontology_from_path (const gchar *ontology_path)
return ret;
}
+/* Unused in case of DISABLE_JOURNAL */
static void
load_ontology_ids_from_journal (GHashTable **uri_id_map_out,
gint *max_id)
@@ -2393,9 +2394,11 @@ insert_uri_in_resource_table (TrackerDBInterface *iface,
return;
}
+#ifndef DISABLE_JOURNAL
if (!in_journal_replay) {
tracker_db_journal_append_resource (id, uri);
}
+#endif /* DISABLE_JOURNAL */
g_object_unref (stmt);
@@ -3530,6 +3533,7 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
iface = tracker_db_manager_get_db_interface ();
+#ifndef DISABLE_JOURNAL
if (journal_check && is_first_time_index) {
/* Call may fail without notice (it's handled) */
if (tracker_db_journal_reader_init (NULL, &internal_error)) {
@@ -3550,6 +3554,7 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
}
}
}
+#endif /* DISABLE_JOURNAL */
env_path = g_getenv ("TRACKER_DB_ONTOLOGIES_DIR");
@@ -3562,6 +3567,7 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
ontologies_dir = g_strdup (env_path);
}
+ /* Runtime false in case of DISABLE_JOURNAL */
if (read_journal) {
in_journal_replay = TRUE;
@@ -3593,6 +3599,7 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
if (is_first_time_index && !read_only) {
sorted = get_ontologies (test_schemas != NULL, ontologies_dir);
+#ifndef DISABLE_JOURNAL
if (!read_journal) {
/* Truncate journal as it does not even contain a single valid transaction
* or is explicitly ignored (journal_check == FALSE, only for test cases) */
@@ -3604,6 +3611,7 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
return FALSE;
}
}
+#endif /* DISABLE_JOURNAL */
/* load ontology from files into memory (max_id starts at zero: first-time) */
@@ -3722,6 +3730,8 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
check_ontology = FALSE;
} else {
if (!read_only) {
+
+#ifndef DISABLE_JOURNAL
tracker_db_journal_init (NULL, FALSE, &internal_error);
if (internal_error) {
@@ -3729,6 +3739,7 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
return FALSE;
}
+#endif /* DISABLE_JOURNAL */
/* Load ontology from database into memory */
db_get_static_data (iface);
@@ -4140,6 +4151,7 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
g_list_free (ontos);
}
+ /* Runtime false in case of DISABLE_JOURNAL */
if (read_journal) {
/* Report OPERATION - STATUS */
busy_status = g_strdup_printf ("%s - %s",
@@ -4230,10 +4242,13 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
void
tracker_data_manager_shutdown (void)
{
+#ifndef DISABLE_JOURNAL
GError *error = NULL;
+#endif /* DISABLE_JOURNAL */
g_return_if_fail (initialized == TRUE);
+#ifndef DISABLE_JOURNAL
/* Make sure we shutdown all other modules we depend on */
tracker_db_journal_shutdown (&error);
@@ -4243,6 +4258,7 @@ tracker_data_manager_shutdown (void)
error->message ? error->message : "No error given");
g_error_free (error);
}
+#endif /* DISABLE_JOURNAL */
tracker_db_manager_shutdown ();
tracker_ontologies_shutdown ();
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 4aba5dc..73f8ce5 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -657,9 +657,11 @@ ensure_resource_id (const gchar *uri,
g_error_free (error);
}
+#ifndef DISABLE_JOURNAL
if (!in_journal_replay) {
tracker_db_journal_append_resource (id, uri);
}
+#endif /* DISABLE_JOURNAL */
g_hash_table_insert (update_buffer.resource_cache, g_strdup (uri), GINT_TO_POINTER (id));
}
@@ -2140,6 +2142,7 @@ tracker_data_delete_statement (const gchar *graph,
if (class != NULL) {
has_persistent = TRUE;
+#ifndef DISABLE_JOURNAL
if (!in_journal_replay) {
tracker_db_journal_append_delete_statement_id (
(graph != NULL ? query_resource_id (graph) : 0),
@@ -2147,6 +2150,8 @@ tracker_data_delete_statement (const gchar *graph,
tracker_data_query_resource_id (predicate),
tracker_class_get_id (class));
}
+#endif /* DISABLE_JOURNAL */
+
cache_delete_resource_type (class, graph, 0);
} else {
g_set_error (error, TRACKER_SPARQL_ERROR, TRACKER_SPARQL_ERROR_UNKNOWN_CLASS,
@@ -2167,37 +2172,42 @@ tracker_data_delete_statement (const gchar *graph,
if (!in_journal_replay && change && !tracker_property_get_transient (field)) {
if (tracker_property_get_data_type (field) == TRACKER_PROPERTY_TYPE_RESOURCE) {
- pred_id = tracker_property_get_id (field);
graph_id = (graph != NULL ? query_resource_id (graph) : 0);
+ pred_id = tracker_property_get_id (field);
object_id = query_resource_id (object);
tried = TRUE;
+#ifndef DISABLE_JOURNAL
tracker_db_journal_append_delete_statement_id (graph_id,
resource_buffer->id,
pred_id,
object_id);
+#endif /* DISABLE_JOURNAL */
} else {
pred_id = tracker_property_get_id (field);
graph_id = (graph != NULL ? query_resource_id (graph) : 0);
object_id = 0;
tried = TRUE;
+#ifndef DISABLE_JOURNAL
if (!tracker_property_get_force_journal (field) &&
g_strcmp0 (graph, TRACKER_MINER_FS_GRAPH_URN) == 0) {
/* do not journal this statement extracted from filesystem */
TrackerProperty *damaged;
damaged = tracker_ontologies_get_property_by_uri (TRACKER_TRACKER_PREFIX "damaged");
+
tracker_db_journal_append_insert_statement (graph_id,
- resource_buffer->id,
- tracker_property_get_id (damaged),
- "true");
+ resource_buffer->id,
+ tracker_property_get_id (damaged),
+ "true");
} else {
tracker_db_journal_append_delete_statement (graph_id,
resource_buffer->id,
pred_id,
object);
}
+#endif /* DISABLE_JOURNAL */
}
}
} else {
@@ -2459,6 +2469,7 @@ tracker_data_insert_statement_with_uri (const gchar *graph,
}
}
+#ifndef DISABLE_JOURNAL
if (!in_journal_replay && change && !tracker_property_get_transient (property)) {
tracker_db_journal_append_insert_statement_id (
(graph != NULL ? query_resource_id (graph) : 0),
@@ -2466,6 +2477,8 @@ tracker_data_insert_statement_with_uri (const gchar *graph,
final_prop_id,
object_id);
}
+#endif /* DISABLE_JOURNAL */
+
}
void
@@ -2538,6 +2551,7 @@ tracker_data_insert_statement_with_string (const gchar *graph,
}
}
+#ifndef DISABLE_JOURNAL
if (!in_journal_replay && change && !tracker_property_get_transient (property)) {
if (!tried) {
graph_id = (graph != NULL ? query_resource_id (graph) : 0);
@@ -2560,6 +2574,7 @@ tracker_data_insert_statement_with_string (const gchar *graph,
object);
}
}
+#endif /* DISABLE_JOURNAL */
}
static void
@@ -2752,6 +2767,7 @@ tracker_data_update_statement_with_uri (const gchar *graph,
}
}
+#ifndef DISABLE_JOURNAL
if (!in_journal_replay && change && !tracker_property_get_transient (property)) {
tracker_db_journal_append_update_statement_id (
(graph != NULL ? query_resource_id (graph) : 0),
@@ -2759,6 +2775,7 @@ tracker_data_update_statement_with_uri (const gchar *graph,
final_prop_id,
object_id);
}
+#endif /* DISABLE_JOURNAL */
}
static void
@@ -2873,6 +2890,7 @@ tracker_data_update_statement_with_string (const gchar *graph,
}
}
+#ifndef DISABLE_JOURNAL
if (!in_journal_replay && change && !tracker_property_get_transient (property)) {
if (!tried) {
graph_id = (graph != NULL ? query_resource_id (graph) : 0);
@@ -2895,6 +2913,7 @@ tracker_data_update_statement_with_string (const gchar *graph,
object);
}
}
+#endif /* DISABLE_JOURNAL */
}
void
@@ -2960,6 +2979,7 @@ tracker_data_begin_transaction (GError **error)
tracker_db_interface_start_transaction (iface);
+#ifndef DISABLE_JOURNAL
if (!in_journal_replay) {
if (in_ontology_transaction) {
GError *n_error = NULL;
@@ -2976,6 +2996,7 @@ tracker_data_begin_transaction (GError **error)
tracker_db_journal_start_transaction (resource_time);
}
}
+#endif /* DISABLE_JOURNAL */
iface = tracker_db_manager_get_db_interface ();
@@ -3023,6 +3044,7 @@ tracker_data_commit_transaction (GError **error)
return;
}
+#ifndef DISABLE_JOURNAL
if (!in_journal_replay) {
if (has_persistent || in_ontology_transaction) {
tracker_db_journal_commit_db_transaction (&actual_error);
@@ -3039,6 +3061,7 @@ tracker_data_commit_transaction (GError **error)
/* Don't return, remainder of the function cleans things up */
}
}
+#endif /* DISABLE_JOURNAL */
get_transaction_modseq ();
if (has_persistent && !in_ontology_transaction) {
@@ -3107,7 +3130,10 @@ tracker_data_rollback_transaction (void)
tracker_db_interface_execute_query (iface, NULL, "PRAGMA cache_size = %d", TRACKER_DB_CACHE_SIZE_DEFAULT);
+ /* Runtime false in case of DISABLE_JOURNAL */
if (!in_journal_replay) {
+
+#ifndef DISABLE_JOURNAL
tracker_db_journal_rollback_transaction (&ignorable);
if (ignorable) {
@@ -3117,6 +3143,8 @@ tracker_data_rollback_transaction (void)
ignorable->message ? ignorable->message : "No error given");
g_error_free (ignorable);
}
+#endif /* DISABLE_JOURNAL */
+
if (rollback_callbacks) {
guint n;
@@ -3198,6 +3226,8 @@ tracker_data_sync (void)
tracker_db_journal_fsync ();
}
+#ifndef DISABLE_JOURNAL
+
void
tracker_data_replay_journal (TrackerBusyCallback busy_callback,
gpointer busy_user_data,
@@ -3502,3 +3532,16 @@ tracker_data_replay_journal (TrackerBusyCallback busy_callback,
tracker_db_journal_reader_shutdown ();
}
}
+
+#else
+
+void
+tracker_data_replay_journal (TrackerBusyCallback busy_callback,
+ gpointer busy_user_data,
+ const gchar *busy_status,
+ GError **error)
+{
+ g_critical ("Not good. We disabled the journal and yet replaying it got called");
+}
+
+#endif /* DISABLE_JOURNAL */
diff --git a/src/libtracker-data/tracker-db-journal.c b/src/libtracker-data/tracker-db-journal.c
index bc50d8e..7800624 100644
--- a/src/libtracker-data/tracker-db-journal.c
+++ b/src/libtracker-data/tracker-db-journal.c
@@ -447,6 +447,10 @@ db_journal_init_file (JournalWriter *jwriter,
int flags;
int mode;
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
jwriter->cur_block_len = 0;
jwriter->cur_pos = 0;
jwriter->cur_entry_amount = 0;
@@ -522,6 +526,10 @@ db_journal_writer_init (JournalWriter *jwriter,
GError *n_error = NULL;
gboolean ret;
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
directory = g_path_get_dirname (filename);
if (g_strcmp0 (directory, ".")) {
mode = S_IRWXU | S_IRWXG | S_IRWXO;
@@ -562,6 +570,10 @@ tracker_db_journal_init (const gchar *filename,
gchar *filename_free = NULL;
GError *n_error = NULL;
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
g_return_val_if_fail (writer.journal == 0, FALSE);
if (filename == NULL) {
@@ -594,6 +606,10 @@ db_journal_ontology_init (GError **error)
gchar *filename;
GError *n_error = NULL;
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
g_return_val_if_fail (ontology_writer.journal == 0, FALSE);
filename = g_build_filename (g_get_user_data_dir (),
@@ -643,6 +659,10 @@ tracker_db_journal_shutdown (GError **error)
GError *n_error = NULL;
gboolean ret;
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
ret = db_journal_writer_shutdown (&writer, &n_error);
if (n_error) {
@@ -663,6 +683,10 @@ tracker_db_journal_get_size (void)
const gchar *
tracker_db_journal_get_filename (void)
{
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
/* Journal doesn't have to be open to get the filename, for example when
* the file didn't exist and it was attempted opened in only read mode. */
return (const gchar*) writer.journal_filename;
@@ -708,6 +732,10 @@ db_journal_writer_start_transaction (JournalWriter *jwriter,
gboolean
tracker_db_journal_start_transaction (time_t time)
{
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
return db_journal_writer_start_transaction (&writer, time,
TRANSACTION_FORMAT_DATA);
}
@@ -718,6 +746,10 @@ tracker_db_journal_start_ontology_transaction (time_t time,
{
GError *n_error = NULL;
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
if (!db_journal_ontology_init (&n_error)) {
if (n_error) {
@@ -779,6 +811,10 @@ tracker_db_journal_append_delete_statement (gint g_id,
gint p_id,
const gchar *object)
{
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
if (current_transaction_format == TRANSACTION_FORMAT_ONTOLOGY) {
return TRUE;
}
@@ -833,6 +869,10 @@ tracker_db_journal_append_delete_statement_id (gint g_id,
gint p_id,
gint o_id)
{
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
if (current_transaction_format == TRANSACTION_FORMAT_ONTOLOGY) {
return TRUE;
}
@@ -889,6 +929,10 @@ tracker_db_journal_append_insert_statement (gint g_id,
gint p_id,
const gchar *object)
{
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
if (current_transaction_format == TRANSACTION_FORMAT_ONTOLOGY) {
return TRUE;
}
@@ -943,6 +987,10 @@ tracker_db_journal_append_insert_statement_id (gint g_id,
gint p_id,
gint o_id)
{
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
if (current_transaction_format == TRANSACTION_FORMAT_ONTOLOGY) {
return TRUE;
}
@@ -999,6 +1047,10 @@ tracker_db_journal_append_update_statement (gint g_id,
gint p_id,
const gchar *object)
{
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
if (current_transaction_format == TRANSACTION_FORMAT_ONTOLOGY) {
return TRUE;
}
@@ -1053,6 +1105,10 @@ tracker_db_journal_append_update_statement_id (gint g_id,
gint p_id,
gint o_id)
{
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
if (current_transaction_format == TRANSACTION_FORMAT_ONTOLOGY) {
return TRUE;
}
@@ -1094,8 +1150,11 @@ tracker_db_journal_append_resource (gint s_id,
{
gboolean ret;
- g_return_val_if_fail (current_transaction_format != TRANSACTION_FORMAT_NONE, FALSE);
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+ g_return_val_if_fail (current_transaction_format != TRANSACTION_FORMAT_NONE, FALSE);
if (current_transaction_format == TRANSACTION_FORMAT_ONTOLOGY) {
ret = db_journal_writer_append_resource (&ontology_writer, s_id, uri);
@@ -1111,6 +1170,10 @@ tracker_db_journal_rollback_transaction (GError **error)
{
GError *n_error = NULL;
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
g_return_val_if_fail (writer.journal > 0, FALSE);
g_return_val_if_fail (current_transaction_format != TRANSACTION_FORMAT_NONE, FALSE);
@@ -1133,6 +1196,10 @@ tracker_db_journal_rollback_transaction (GError **error)
gboolean
tracker_db_journal_truncate (gsize new_size)
{
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
g_return_val_if_fail (writer.journal > 0, FALSE);
return (ftruncate (writer.journal, new_size) != -1);
@@ -1192,6 +1259,10 @@ tracker_db_journal_commit_db_transaction (GError **error)
gboolean ret;
GError *n_error = NULL;
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
g_return_val_if_fail (current_transaction_format != TRANSACTION_FORMAT_NONE, FALSE);
if (current_transaction_format == TRANSACTION_FORMAT_ONTOLOGY) {
@@ -1222,6 +1293,10 @@ tracker_db_journal_commit_db_transaction (GError **error)
gboolean
tracker_db_journal_fsync (void)
{
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
g_return_val_if_fail (writer.journal > 0, FALSE);
return fsync (writer.journal) == 0;
@@ -1408,6 +1483,10 @@ tracker_db_journal_reader_init (const gchar *filename,
gboolean ret;
GError *n_error = NULL;
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
ret = db_journal_reader_init (&reader, TRUE, filename, &n_error);
if (n_error) {
@@ -1425,6 +1504,10 @@ tracker_db_journal_reader_ontology_init (const gchar *filename,
gboolean result;
GError *n_error = NULL;
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
/* Used mostly for testing */
if (G_UNLIKELY (filename)) {
filename_used = g_strdup (filename);
@@ -1450,6 +1533,10 @@ tracker_db_journal_reader_ontology_init (const gchar *filename,
gsize
tracker_db_journal_reader_get_size_of_correct (void)
{
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
g_return_val_if_fail (reader.file != NULL, FALSE);
return (gsize) (reader.last_success - reader.start);
@@ -1541,6 +1628,10 @@ db_journal_reader_shutdown (JournalReader *jreader)
gboolean
tracker_db_journal_reader_shutdown (void)
{
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
return db_journal_reader_shutdown (&reader);
}
@@ -1853,6 +1944,10 @@ db_journal_reader_next (JournalReader *jreader, gboolean global_reader, GError *
gboolean
tracker_db_journal_reader_next (GError **error)
{
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
return db_journal_reader_next (&reader, TRUE, error);
}
@@ -1865,6 +1960,10 @@ tracker_db_journal_reader_verify_last (const gchar *filename,
JournalReader jreader = { 0 };
GError *n_error = NULL;
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
if (db_journal_reader_init (&jreader, FALSE, filename, &n_error)) {
if (jreader.end != jreader.current) {
@@ -1903,6 +2002,10 @@ gboolean
tracker_db_journal_reader_get_resource (gint *id,
const gchar **uri)
{
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
g_return_val_if_fail (reader.file != NULL || reader.stream != NULL, FALSE);
g_return_val_if_fail (reader.type == TRACKER_DB_JOURNAL_RESOURCE, FALSE);
@@ -1918,6 +2021,10 @@ tracker_db_journal_reader_get_statement (gint *g_id,
gint *p_id,
const gchar **object)
{
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
g_return_val_if_fail (reader.file != NULL || reader.stream != NULL, FALSE);
g_return_val_if_fail (reader.type == TRACKER_DB_JOURNAL_INSERT_STATEMENT ||
reader.type == TRACKER_DB_JOURNAL_DELETE_STATEMENT ||
@@ -1940,6 +2047,10 @@ tracker_db_journal_reader_get_statement_id (gint *g_id,
gint *p_id,
gint *o_id)
{
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
g_return_val_if_fail (reader.file != NULL || reader.stream != NULL, FALSE);
g_return_val_if_fail (reader.type == TRACKER_DB_JOURNAL_INSERT_STATEMENT_ID ||
reader.type == TRACKER_DB_JOURNAL_DELETE_STATEMENT_ID ||
@@ -1963,6 +2074,10 @@ tracker_db_journal_reader_get_progress (void)
guint current_file;
static guint total_chunks = 0;
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
current_file = reader.current_file == 0 ? total_chunks -1 : reader.current_file -1;
if (!rotating_settings.rotate_progress_flag) {
@@ -2081,6 +2196,10 @@ tracker_db_journal_rotate (GError **error)
GError *n_error = NULL;
gboolean ret;
+#ifdef DISABLE_JOURNAL
+ g_critical ("Journal is disabled, yet a journal function got called");
+#endif
+
if (max == 0) {
gchar *directory;
GDir *journal_dir;
diff --git a/src/libtracker-data/tracker-db-manager.c b/src/libtracker-data/tracker-db-manager.c
index 85bf305..c8a8179 100644
--- a/src/libtracker-data/tracker-db-manager.c
+++ b/src/libtracker-data/tracker-db-manager.c
@@ -390,6 +390,7 @@ db_interface_create (TrackerDB db,
static void
db_manager_remove_journal (void)
{
+#ifndef DISABLE_JOURNAL
gchar *path;
gchar *directory, *rotate_to = NULL;
gsize chunk_size;
@@ -458,6 +459,7 @@ db_manager_remove_journal (void)
g_message ("%s", g_strerror (errno));
}
g_free (path);
+#endif /* DISABLE_JOURNAL */
}
static void
@@ -784,6 +786,9 @@ tracker_db_manager_init_locations (void)
"data",
NULL);
+ /* For DISABLE_JOURNAL case we should use g_get_user_data_dir here. For now
+ * keeping this as-is */
+
data_dir = g_build_filename (g_get_user_cache_dir (),
"tracker",
NULL);
@@ -1035,11 +1040,14 @@ tracker_db_manager_init (TrackerDBManagerFlags flags,
} else if ((flags & TRACKER_DB_MANAGER_READONLY) == 0) {
/* do not do shutdown check for read-only mode (direct access) */
gboolean must_recreate;
+#ifndef DISABLE_JOURNAL
gchar *journal_filename;
+#endif /* DISABLE_JOURNAL */
/* Load databases */
g_message ("Loading databases files...");
+#ifndef DISABLE_JOURNAL
journal_filename = g_build_filename (g_get_user_data_dir (),
"tracker",
"data",
@@ -1050,6 +1058,7 @@ tracker_db_manager_init (TrackerDBManagerFlags flags,
NULL);
g_free (journal_filename);
+#endif /* DISABLE_JOURNAL */
if (!must_recreate && g_file_test (in_use_filename, G_FILE_TEST_EXISTS)) {
gsize size = 0;
@@ -1059,7 +1068,9 @@ tracker_db_manager_init (TrackerDBManagerFlags flags,
for (i = 1; i < G_N_ELEMENTS (dbs) && !must_recreate; i++) {
struct stat st;
TrackerDBStatement *stmt;
+#ifndef DISABLE_JOURNAL
gchar *busy_status;
+#endif /* DISABLE_JOURNAL */
if (g_stat (dbs[i].abs_filename, &st) == 0) {
size = st.st_size;
@@ -1087,6 +1098,7 @@ tracker_db_manager_init (TrackerDBManagerFlags flags,
loaded = TRUE;
+#ifndef DISABLE_JOURNAL
/* Report OPERATION - STATUS */
busy_status = g_strdup_printf ("%s - %s",
busy_operation,
@@ -1129,6 +1141,7 @@ tracker_db_manager_init (TrackerDBManagerFlags flags,
g_object_unref (cursor);
}
}
+#endif /* DISABLE_JOURNAL */
/* ensure that database has been initialized by an earlier tracker-store start
by checking whether Resource table exists */
@@ -1148,8 +1161,12 @@ tracker_db_manager_init (TrackerDBManagerFlags flags,
}
if (must_recreate) {
-
- g_message ("Database severely damaged. We will recreate it and replay the journal if available.");
+ g_message ("Database severely damaged. We will recreate it"
+#ifndef DISABLE_JOURNAL
+ " and replay the journal if available.");
+#else
+ ".");
+#endif /* DISABLE_JOURNAL */
perform_recreate (first_time, &internal_error);
if (internal_error) {
@@ -1304,12 +1321,15 @@ void
tracker_db_manager_move_to_temp (void)
{
guint i;
- gchar *cpath, *filename;
+ gchar *filename;
+#ifndef DISABLE_JOURNAL
+ gchar *cpath;
gchar *fullpath;
gchar *directory, *rotate_to = NULL;
const gchar *dirs[3] = { NULL, NULL, NULL };
gsize chunk_size = 0;
gboolean do_rotate = FALSE;
+#endif /* DISABLE_JOURNAL */
g_return_if_fail (initialized != FALSE);
@@ -1324,7 +1344,7 @@ tracker_db_manager_move_to_temp (void)
}
g_free (filename);
}
-
+#ifndef DISABLE_JOURNAL
cpath = g_strdup (tracker_db_journal_get_filename ());
directory = g_path_get_dirname (cpath);
@@ -1381,6 +1401,7 @@ tracker_db_manager_move_to_temp (void)
}
g_free (cpath);
g_free (filename);
+#endif /* DISABLE_JOURNAL */
}
@@ -1388,12 +1409,15 @@ void
tracker_db_manager_restore_from_temp (void)
{
guint i;
- gchar *cpath, *filename;
+ gchar *filename;
+#ifndef DISABLE_JOURNAL
+ gchar *cpath;
gchar *fullpath;
gchar *directory, *rotate_to = NULL;
const gchar *dirs[3] = { NULL, NULL, NULL };
gsize chunk_size = 0;
gboolean do_rotate = FALSE;
+#endif /* DISABLE_JOURNAL */
g_return_if_fail (locations_initialized != FALSE);
@@ -1409,6 +1433,7 @@ tracker_db_manager_restore_from_temp (void)
g_free (filename);
}
+#ifndef DISABLE_JOURNAL
cpath = g_strdup (tracker_db_journal_get_filename ());
filename = g_strdup_printf ("%s.tmp", cpath);
g_message (" Renaming journal:'%s' -> '%s'",
@@ -1468,17 +1493,21 @@ tracker_db_manager_restore_from_temp (void)
g_free (rotate_to);
g_free (directory);
g_free (cpath);
+#endif /* DISABLE_JOURNAL */
}
void
tracker_db_manager_remove_temp (void)
{
guint i;
- gchar *cpath, *filename;
+ gchar *filename;
+#ifndef DISABLE_JOURNAL
+ gchar *cpath;
gchar *directory, *rotate_to = NULL;
gsize chunk_size = 0;
gboolean do_rotate = FALSE;
const gchar *dirs[3] = { NULL, NULL, NULL };
+#endif /* DISABLE_JOURNAL */
g_return_if_fail (locations_initialized != FALSE);
@@ -1494,6 +1523,7 @@ tracker_db_manager_remove_temp (void)
g_free (filename);
}
+#ifndef DISABLE_JOURNAL
cpath = g_strdup (tracker_db_journal_get_filename ());
filename = g_strdup_printf ("%s.tmp", cpath);
g_message (" Removing temp journal:'%s'",
@@ -1547,6 +1577,7 @@ tracker_db_manager_remove_temp (void)
g_free (rotate_to);
g_free (directory);
+#endif /* DISABLE_JOURNAL */
}
void
diff --git a/src/tracker-control/tracker-control-general.c b/src/tracker-control/tracker-control-general.c
index 3f9f3ff..b597e88 100644
--- a/src/tracker-control/tracker-control-general.c
+++ b/src/tracker-control/tracker-control-general.c
@@ -442,12 +442,12 @@ tracker_control_general_run (void)
if (hard_reset || soft_reset) {
guint log_handler_id;
+#ifndef DISABLE_JOURNAL
const gchar *rotate_to = NULL;
TrackerDBConfig *db_config;
gsize chunk_size;
gint chunk_size_mb;
-
- db_config = tracker_db_config_new ();
+#endif /* DISABLE_JOURNAL */
/* Set log handler for library messages */
log_handler_id = g_log_set_handler (NULL,
@@ -457,6 +457,9 @@ tracker_control_general_run (void)
g_log_set_default_handler (log_handler, NULL);
+#ifndef DISABLE_JOURNAL
+ db_config = tracker_db_config_new ();
+
chunk_size_mb = tracker_db_config_get_journal_chunk_size (db_config);
chunk_size = (gsize) ((gsize) chunk_size_mb * (gsize) 1024 * (gsize) 1024);
rotate_to = tracker_db_config_get_journal_rotate_destination (db_config);
@@ -467,6 +470,8 @@ tracker_control_general_run (void)
g_object_unref (db_config);
+#endif /* DISABLE_JOURNAL */
+
/* Clean up (select_cache_size and update_cache_size don't matter here) */
if (!tracker_db_manager_init (TRACKER_DB_MANAGER_REMOVE_ALL,
NULL,
@@ -483,12 +488,15 @@ tracker_control_general_run (void)
return EXIT_FAILURE;
}
-
+#ifndef DISABLE_JOURNAL
tracker_db_journal_init (NULL, FALSE, NULL);
+#endif /* DISABLE_JOURNAL */
tracker_db_manager_remove_all (hard_reset);
tracker_db_manager_shutdown ();
+#ifndef DISABLE_JOURNAL
tracker_db_journal_shutdown (NULL);
+#endif /* DISABLE_JOURNAL */
/* Unset log handler */
g_log_remove_handler (NULL, log_handler_id);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]