[tracker/wip/carlosg/domain-ontologies: 37/93] libtracker-data: Remove another filename argument in TrackerDBJournal



commit 63eb00d2a2e6afec5c18d3a4fd701d35c1f0c78a
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Jun 5 19:31:40 2017 +0200

    libtracker-data: Remove another filename argument in TrackerDBJournal
    
    Which also makes it use the right data location for it.

 src/libtracker-data/tracker-db-journal.c |   14 +++++++++++---
 src/libtracker-data/tracker-db-journal.h |    3 +--
 src/libtracker-data/tracker-db-manager.c |   11 +----------
 3 files changed, 13 insertions(+), 15 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-journal.c b/src/libtracker-data/tracker-db-journal.c
index 166f963..11ff97a 100644
--- a/src/libtracker-data/tracker-db-journal.c
+++ b/src/libtracker-data/tracker-db-journal.c
@@ -1863,14 +1863,19 @@ tracker_db_journal_reader_next (TrackerDBJournalReader  *reader,
 }
 
 gboolean
-tracker_db_journal_reader_verify_last (const gchar  *filename,
-                                       GFile        *data_location,
-                                       GError      **error)
+tracker_db_journal_reader_verify_last (GFile   *data_location,
+                                       GError **error)
 {
        guint32 entry_size_check;
        gboolean success = FALSE;
        TrackerDBJournalReader jreader = { 0 };
        GError *n_error = NULL;
+       gchar *filename;
+       GFile *child;
+
+       child = g_file_get_child (data_location, TRACKER_DB_JOURNAL_FILENAME);
+       filename = g_file_get_path (child);
+       g_object_unref (child);
 
        if (db_journal_reader_init (&jreader, FALSE, filename, data_location, &n_error)) {
 
@@ -1878,6 +1883,7 @@ tracker_db_journal_reader_verify_last (const gchar  *filename,
                        entry_size_check = read_uint32 (jreader.end - 4);
 
                        if (jreader.end - entry_size_check < jreader.current) {
+                               g_free (filename);
                                g_set_error (error, TRACKER_DB_JOURNAL_ERROR,
                                             TRACKER_DB_JOURNAL_ERROR_DAMAGED_JOURNAL_ENTRY,
                                             "Damaged journal entry at end of journal");
@@ -1893,6 +1899,8 @@ tracker_db_journal_reader_verify_last (const gchar  *filename,
                }
        }
 
+       g_free (filename);
+
        if (n_error) {
                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 ed4b64d..30c064e 100644
--- a/src/libtracker-data/tracker-db-journal.h
+++ b/src/libtracker-data/tracker-db-journal.h
@@ -146,8 +146,7 @@ gboolean     tracker_db_journal_reader_get_statement_id      (TrackerDBJournalRe
 gsize        tracker_db_journal_reader_get_size_of_correct   (TrackerDBJournalReader  *reader);
 gdouble      tracker_db_journal_reader_get_progress          (TrackerDBJournalReader  *reader);
 
-gboolean     tracker_db_journal_reader_verify_last           (const gchar             *filename,
-                                                              GFile                   *data_location,
+gboolean     tracker_db_journal_reader_verify_last           (GFile                   *data_location,
                                                               GError                 **error);
 
 G_END_DECLS
diff --git a/src/libtracker-data/tracker-db-manager.c b/src/libtracker-data/tracker-db-manager.c
index 249ca74..6e955f2 100644
--- a/src/libtracker-data/tracker-db-manager.c
+++ b/src/libtracker-data/tracker-db-manager.c
@@ -1011,22 +1011,13 @@ db_manager_init_unlocked (TrackerDBManagerFlags   flags,
        } else if ((flags & TRACKER_DB_MANAGER_READONLY) == 0) {
                /* do not do shutdown check for read-only mode (direct access) */
                gboolean must_recreate = FALSE;
-#ifndef DISABLE_JOURNAL
-               gchar *journal_filename, *jfname;
-#endif /* DISABLE_JOURNAL */
 
                /* Load databases */
                g_info ("Loading databases files...");
 
 #ifndef DISABLE_JOURNAL
-               journal_filename = g_build_filename (user_data_dir,
-                                                    TRACKER_DB_JOURNAL_FILENAME,
-                                                    NULL);
-               must_recreate = !tracker_db_journal_reader_verify_last (journal_filename,
-                                                                       data_location,
+               must_recreate = !tracker_db_journal_reader_verify_last (data_location,
                                                                        NULL);
-
-               g_free (journal_filename);
 #endif /* DISABLE_JOURNAL */
 
                if (!must_recreate && g_file_test (in_use_filename, G_FILE_TEST_EXISTS)) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]