[tracker/wip/carlosg/domain-ontologies: 29/55] libtracker-data: Remove filename argument from journal init funcs
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/domain-ontologies: 29/55] libtracker-data: Remove filename argument from journal init funcs
- Date: Sun, 11 Jun 2017 15:05:44 +0000 (UTC)
commit d86447a9027bb700afd2bd0e6f54057db864c455
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Jun 4 16:35:54 2017 +0200
libtracker-data: Remove filename argument from journal init funcs
We already pass a GFile with the location, just use the predefined basename
for these.
src/libtracker-data/tracker-data-backup.c | 2 +-
src/libtracker-data/tracker-data-manager.c | 13 ++---
src/libtracker-data/tracker-data-update.c | 4 +-
src/libtracker-data/tracker-db-journal.c | 81 ++++++++++------------------
src/libtracker-data/tracker-db-journal.h | 10 +---
src/tracker/tracker-reset.c | 2 +-
tests/libtracker-data/tracker-db-journal.c | 16 ++----
7 files changed, 45 insertions(+), 83 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-backup.c b/src/libtracker-data/tracker-data-backup.c
index d7b3aa9..2172da2 100644
--- a/src/libtracker-data/tracker-data-backup.c
+++ b/src/libtracker-data/tracker-data-backup.c
@@ -667,7 +667,7 @@ tracker_data_backup_restore (GFile *journal,
tracker_db_manager_set_need_mtime_check (TRUE);
#ifndef DISABLE_JOURNAL
- tracker_db_journal_init (NULL, cache_location, data_location, FALSE, &n_error);
+ tracker_db_journal_init (data_location, FALSE, &n_error);
if (n_error) {
if (!info->error) {
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index befaf30..ca77c7b 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -3841,7 +3841,7 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
#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, data_location, &internal_error)) {
+ if (tracker_db_journal_reader_init (data_location, &internal_error)) {
if (tracker_db_journal_reader_next (NULL)) {
/* journal with at least one valid transaction
is required to trigger journal replay */
@@ -3902,7 +3902,7 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
if (read_journal) {
in_journal_replay = TRUE;
- if (tracker_db_journal_reader_ontology_init (NULL, data_location, &internal_error)) {
+ if (tracker_db_journal_reader_ontology_init (data_location, &internal_error)) {
/* Load ontology IDs from journal into memory */
load_ontology_ids_from_journal (&uri_id_map, &max_id);
@@ -3949,8 +3949,7 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
* contain a single valid transaction, or is explicitly ignored
* (journal_check == FALSE, only for test cases)
*/
- tracker_db_journal_init (NULL, cache_location, data_location,
- !in_journal_replay, &internal_error);
+ tracker_db_journal_init (data_location, !in_journal_replay, &internal_error);
if (internal_error) {
g_propagate_error (error, internal_error);
@@ -4097,8 +4096,7 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
if (!read_only) {
#ifndef DISABLE_JOURNAL
- tracker_db_journal_init (NULL, cache_location, data_location,
- FALSE, &internal_error);
+ tracker_db_journal_init (data_location, FALSE, &internal_error);
if (internal_error) {
g_propagate_error (error, internal_error);
@@ -4638,8 +4636,7 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
in_journal_replay = FALSE;
/* open journal for writing */
- tracker_db_journal_init (NULL, cache_location, data_location,
- FALSE, &internal_error);
+ tracker_db_journal_init (data_location, FALSE, &internal_error);
if (internal_error) {
g_hash_table_unref (uri_id_map);
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 1fa201e..876610c 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -3570,7 +3570,7 @@ tracker_data_replay_journal (TrackerBusyCallback busy_callback,
rdf_type = tracker_ontologies_get_rdf_type ();
data_location = tracker_data_manager_get_data_location ();
- tracker_db_journal_reader_init (NULL, data_location, &n_error);
+ tracker_db_journal_reader_init (data_location, &n_error);
g_object_unref (data_location);
if (n_error) {
/* This is fatal (doesn't happen when file doesn't exist, does happen
@@ -3839,7 +3839,7 @@ tracker_data_replay_journal (TrackerBusyCallback busy_callback,
cache_location = tracker_data_manager_get_cache_location();
data_location = tracker_data_manager_get_data_location();
- tracker_db_journal_init (NULL, cache_location, data_location, FALSE, &n_error);
+ tracker_db_journal_init (data_location, FALSE, &n_error);
g_object_unref (cache_location);
g_object_unref (data_location);
diff --git a/src/libtracker-data/tracker-db-journal.c b/src/libtracker-data/tracker-db-journal.c
index b064e7d..db4c054 100644
--- a/src/libtracker-data/tracker-db-journal.c
+++ b/src/libtracker-data/tracker-db-journal.c
@@ -570,34 +570,25 @@ db_journal_writer_init (JournalWriter *jwriter,
}
gboolean
-tracker_db_journal_init (const gchar *filename,
- GFile *cache_location,
- GFile *data_location,
- gboolean truncate,
- GError **error)
+tracker_db_journal_init (GFile *data_location,
+ gboolean truncate,
+ GError **error)
{
gboolean ret;
- const gchar *filename_use;
- gchar *filename_free = NULL;
+ gchar *filename;
GError *n_error = NULL;
+ GFile *child;
g_return_val_if_fail (writer.journal == 0, FALSE);
- if (filename == NULL) {
- GFile *child;
-
- child = g_file_get_child (data_location, TRACKER_DB_JOURNAL_FILENAME);
- filename_use = g_file_get_path (child);
- g_object_unref (child);
+ child = g_file_get_child (data_location, TRACKER_DB_JOURNAL_FILENAME);
+ filename = g_file_get_path (child);
+ g_object_unref (child);
- g_assert (filename_use != NULL);
- filename_free = (gchar *) filename_use;
- } else {
- filename_use = filename;
- }
+ g_assert (filename != NULL);
- ret = db_journal_writer_init (&writer, truncate, TRUE, filename_use, data_location, &n_error);
- g_free (filename_free);
+ ret = db_journal_writer_init (&writer, truncate, TRUE, filename, data_location, &n_error);
+ g_free (filename);
if (!ret) {
g_propagate_error (error, n_error);
@@ -1403,27 +1394,20 @@ db_journal_reader_init (JournalReader *jreader,
}
gboolean
-tracker_db_journal_reader_init (const gchar *filename,
- GFile *data_location,
- GError **error)
+tracker_db_journal_reader_init (GFile *data_location,
+ GError **error)
{
gboolean ret;
GError *n_error = NULL;
- gchar *filename_used;
-
- /* Used mostly for testing */
- if (G_UNLIKELY (filename)) {
- filename_used = g_strdup (filename);
- } else {
- GFile *child;
+ gchar *filename;
+ GFile *child;
- child = g_file_get_child (data_location, TRACKER_DB_JOURNAL_FILENAME);
- filename_used = g_file_get_path (child);
- g_object_unref (child);
- }
+ child = g_file_get_child (data_location, TRACKER_DB_JOURNAL_FILENAME);
+ filename = g_file_get_path (child);
+ g_object_unref (child);
- ret = db_journal_reader_init (&reader, TRUE, filename_used, data_location, &n_error);
- g_free (filename_used);
+ ret = db_journal_reader_init (&reader, TRUE, filename, data_location, &n_error);
+ g_free (filename);
if (n_error) {
g_propagate_error (error, n_error);
@@ -1433,27 +1417,20 @@ tracker_db_journal_reader_init (const gchar *filename,
}
gboolean
-tracker_db_journal_reader_ontology_init (const gchar *filename,
- GFile *data_location,
- GError **error)
+tracker_db_journal_reader_ontology_init (GFile *data_location,
+ GError **error)
{
- gchar *filename_used;
+ gchar *filename;
gboolean result;
GError *n_error = NULL;
+ GFile *child;
- /* Used mostly for testing */
- if (G_UNLIKELY (filename)) {
- filename_used = g_strdup (filename);
- } else {
- GFile *child;
-
- child = g_file_get_child (data_location, TRACKER_DB_JOURNAL_ONTOLOGY_FILENAME);
- filename_used = g_file_get_path (child);
- g_object_unref (child);
- }
+ child = g_file_get_child (data_location, TRACKER_DB_JOURNAL_ONTOLOGY_FILENAME);
+ filename = g_file_get_path (child);
+ g_object_unref (child);
- result = db_journal_reader_init (&reader, TRUE, filename_used, data_location, &n_error);
- g_free (filename_used);
+ result = db_journal_reader_init (&reader, TRUE, filename, data_location, &n_error);
+ g_free (filename);
if (!result) {
g_propagate_error (error, n_error);
diff --git a/src/libtracker-data/tracker-db-journal.h b/src/libtracker-data/tracker-db-journal.h
index 6bec56f..c427bfc 100644
--- a/src/libtracker-data/tracker-db-journal.h
+++ b/src/libtracker-data/tracker-db-journal.h
@@ -59,9 +59,7 @@ GQuark tracker_db_journal_error_quark (void);
/*
* Writer API
*/
-gboolean tracker_db_journal_init (const gchar *filename,
- GFile *cache_location,
- GFile *data_location,
+gboolean tracker_db_journal_init (GFile *data_location,
gboolean truncate,
GError **error);
gboolean tracker_db_journal_shutdown (GError **error);
@@ -117,11 +115,9 @@ gboolean tracker_db_journal_truncate (gsize new_size);
/*
* Reader API
*/
-gboolean tracker_db_journal_reader_init (const gchar *filename,
- GFile *data_location,
+gboolean tracker_db_journal_reader_init (GFile *data_location,
GError **error);
-gboolean tracker_db_journal_reader_ontology_init (const gchar *filename,
- GFile *data_location,
+gboolean tracker_db_journal_reader_ontology_init (GFile *data_location,
GError **error);
gboolean tracker_db_journal_reader_shutdown (void);
TrackerDBJournalEntryType
diff --git a/src/tracker/tracker-reset.c b/src/tracker/tracker-reset.c
index 89aa641..0093182 100644
--- a/src/tracker/tracker-reset.c
+++ b/src/tracker/tracker-reset.c
@@ -319,7 +319,7 @@ reset_run (void)
return EXIT_FAILURE;
}
#ifndef DISABLE_JOURNAL
- tracker_db_journal_init (NULL, NULL, data_location, FALSE, NULL);
+ tracker_db_journal_init (data_location, FALSE, NULL);
#endif /* DISABLE_JOURNAL */
tracker_db_manager_remove_all (hard_reset);
diff --git a/tests/libtracker-data/tracker-db-journal.c b/tests/libtracker-data/tracker-db-journal.c
index 1a78431..42f87da 100644
--- a/tests/libtracker-data/tracker-db-journal.c
+++ b/tests/libtracker-data/tracker-db-journal.c
@@ -44,7 +44,7 @@ test_init_and_shutdown (void)
/* check double init/shutdown */
tracker_db_journal_set_rotating (FALSE, G_MAXSIZE, NULL);
- result = tracker_db_journal_init (path, NULL, data_location, FALSE, &error);
+ result = tracker_db_journal_init (data_location, FALSE, &error);
g_assert_no_error (error);
g_assert (result == TRUE);
@@ -53,7 +53,7 @@ test_init_and_shutdown (void)
g_assert (result == TRUE);
tracker_db_journal_set_rotating (FALSE, G_MAXSIZE, NULL);
- result = tracker_db_journal_init (path, NULL, data_location, FALSE, &error);
+ result = tracker_db_journal_init (data_location, FALSE, &error);
g_assert_no_error (error);
g_assert (result == TRUE);
@@ -85,7 +85,7 @@ test_write_functions (void)
g_object_unref (child);
tracker_db_journal_set_rotating (FALSE, G_MAXSIZE, NULL);
- tracker_db_journal_init (path, NULL, data_location, FALSE, &error);
+ tracker_db_journal_init (data_location, FALSE, &error);
g_object_unref (data_location);
g_assert_no_error (error);
@@ -183,14 +183,10 @@ test_read_functions (void)
data_location = g_file_new_for_path (path);
g_free (path);
- child = g_file_get_child (data_location, "tracker-store.journal");
- filename = g_file_get_path (child);
- g_object_unref (child);
-
/* NOTE: we don't unlink here so we can use the data from the write tests */
/* Create an iterator */
- result = tracker_db_journal_reader_init (filename, data_location, &error);
+ result = tracker_db_journal_reader_init (data_location, &error);
g_free (filename);
g_object_unref (data_location);
g_assert_no_error (error);
@@ -413,9 +409,5 @@ main (int argc, char **argv)
g_unlink (path);
g_free (path);
- path = g_build_filename (TOP_BUILDDIR, "tests", "libtracker-data", "dconf", "user", NULL);
- g_unlink (path);
- g_free (path);
-
return result;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]