[tracker/wip/carlosg/domain-ontologies: 68/76] libtracker-data: Fix compilation on DISABLE_JOURNAL
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/domain-ontologies: 68/76] libtracker-data: Fix compilation on DISABLE_JOURNAL
- Date: Thu, 29 Jun 2017 18:55:19 +0000 (UTC)
commit 8cbf96b6dfca47a3291e329836d9cffbee2996e6
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Jun 22 00:18:04 2017 +0200
libtracker-data: Fix compilation on DISABLE_JOURNAL
Pass the TrackerDataManager down tracker_backup_save(), so we can
fetch the DB file underneath.
src/libtracker-data/libtracker-data.vapi | 2 +-
src/libtracker-data/tracker-data-backup.c | 14 +++++++++++---
src/libtracker-data/tracker-data-backup.h | 3 ++-
src/libtracker-data/tracker-db-backup.c | 15 ++++++++++-----
src/libtracker-data/tracker-db-backup.h | 1 +
src/tracker-store/tracker-backup.vala | 3 ++-
tests/libtracker-data/tracker-backup-test.c | 3 ++-
7 files changed, 29 insertions(+), 12 deletions(-)
---
diff --git a/src/libtracker-data/libtracker-data.vapi b/src/libtracker-data/libtracker-data.vapi
index 21bead8..b351159 100644
--- a/src/libtracker-data/libtracker-data.vapi
+++ b/src/libtracker-data/libtracker-data.vapi
@@ -225,7 +225,7 @@ namespace Tracker {
public int query_resource_id (Data.Manager manager, string uri);
public DBCursor query_sparql_cursor (Data.Manager manager, string query) throws Sparql.Error;
- public void backup_save (GLib.File destination, GLib.File data_location, owned BackupFinished
callback);
+ public void backup_save (Data.Manager manager, GLib.File destination, GLib.File
data_location, owned BackupFinished callback);
public void backup_restore (Data.Manager manager, 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-backup.h")]
diff --git a/src/libtracker-data/tracker-data-backup.c b/src/libtracker-data/tracker-data-backup.c
index 9cd3300..c252ad9 100644
--- a/src/libtracker-data/tracker-data-backup.c
+++ b/src/libtracker-data/tracker-data-backup.c
@@ -408,7 +408,8 @@ restore_from_temp (GFile *cache_location,
}
void
-tracker_data_backup_save (GFile *destination,
+tracker_data_backup_save (TrackerDataManager *data_manager,
+ GFile *destination,
GFile *data_location,
TrackerDataBackupFinished callback,
gpointer user_data,
@@ -528,6 +529,8 @@ tracker_data_backup_save (GFile *destination,
g_strfreev (argv);
#else
BackupSaveInfo *info;
+ TrackerDBManager *db_manager;
+ GFile *db_file;
info = g_new0 (BackupSaveInfo, 1);
info->destination = g_object_ref (destination);
@@ -535,10 +538,15 @@ tracker_data_backup_save (GFile *destination,
info->user_data = user_data;
info->destroy = destroy;
- tracker_db_backup_save (destination,
- on_backup_finished,
+ db_manager = tracker_data_manager_get_db_manager (data_manager);
+ db_file = g_file_new_for_path (tracker_db_manager_get_file (db_manager));
+
+ tracker_db_backup_save (destination, db_file,
+ on_backup_finished,
info,
NULL);
+
+ g_object_unref (db_file);
#endif /* DISABLE_JOURNAL */
}
diff --git a/src/libtracker-data/tracker-data-backup.h b/src/libtracker-data/tracker-data-backup.h
index 6b861bf..acc63f1 100644
--- a/src/libtracker-data/tracker-data-backup.h
+++ b/src/libtracker-data/tracker-data-backup.h
@@ -43,7 +43,8 @@ typedef enum {
typedef void (*TrackerDataBackupFinished) (GError *error, gpointer user_data);
GQuark tracker_data_backup_error_quark (void);
-void tracker_data_backup_save (GFile *destination,
+void tracker_data_backup_save (TrackerDataManager *manager,
+ GFile *destination,
GFile *data_location,
TrackerDataBackupFinished callback,
gpointer user_data,
diff --git a/src/libtracker-data/tracker-db-backup.c b/src/libtracker-data/tracker-db-backup.c
index fc69bfe..49bbcb3 100644
--- a/src/libtracker-data/tracker-db-backup.c
+++ b/src/libtracker-data/tracker-db-backup.c
@@ -38,6 +38,7 @@
typedef struct {
GFile *destination;
+ GFile *file;
TrackerDBBackupFinished callback;
gpointer user_data;
GDestroyNotify destroy;
@@ -71,6 +72,10 @@ backup_info_free (gpointer user_data)
g_object_unref (info->destination);
}
+ if (info->file) {
+ g_object_unref (info->file);
+ }
+
if (info->destroy) {
info->destroy (info->user_data);
}
@@ -87,18 +92,15 @@ backup_job (GTask *task,
GCancellable *cancellable)
{
BackupInfo *info = task_data;
- TrackerDBManager *db_manager;
- const gchar *src_path;
GFile *parent_file, *temp_file;
- gchar *temp_path;
+ gchar *temp_path, *src_path;
sqlite3 *src_db = NULL;
sqlite3 *temp_db = NULL;
sqlite3_backup *backup = NULL;
- db_manager = tracker_data_manager_get_db_manager ();
- src_path = tracker_db_manager_get_file (db_manager);
+ src_path = g_file_get_path (info->file);
parent_file = g_file_get_parent (info->destination);
temp_file = g_file_get_child (parent_file, TRACKER_DB_BACKUP_META_FILENAME_T);
g_file_delete (temp_file, NULL, NULL);
@@ -160,6 +162,7 @@ backup_job (GTask *task,
&info->error);
}
+ g_free (src_path);
g_free (temp_path);
g_object_unref (temp_file);
g_object_unref (parent_file);
@@ -170,6 +173,7 @@ backup_job (GTask *task,
void
tracker_db_backup_save (GFile *destination,
+ GFile *file,
TrackerDBBackupFinished callback,
gpointer user_data,
GDestroyNotify destroy)
@@ -180,6 +184,7 @@ tracker_db_backup_save (GFile *destination,
info = g_slice_new0 (BackupInfo);
info->destination = g_object_ref (destination);
+ info->file = g_object_ref (file);
info->callback = callback;
info->user_data = user_data;
diff --git a/src/libtracker-data/tracker-db-backup.h b/src/libtracker-data/tracker-db-backup.h
index 67302b8..af68eb9 100644
--- a/src/libtracker-data/tracker-db-backup.h
+++ b/src/libtracker-data/tracker-db-backup.h
@@ -40,6 +40,7 @@ typedef void (*TrackerDBBackupFinished) (GError *error, gpointer user_data);
GQuark tracker_db_backup_error_quark (void);
void tracker_db_backup_save (GFile *destination,
+ GFile *file,
TrackerDBBackupFinished callback,
gpointer user_data,
GDestroyNotify destroy);
diff --git a/src/tracker-store/tracker-backup.vala b/src/tracker-store/tracker-backup.vala
index 1b01b81..a0876f7 100644
--- a/src/tracker-store/tracker-backup.vala
+++ b/src/tracker-store/tracker-backup.vala
@@ -40,7 +40,8 @@ public class Tracker.Backup : Object {
yield Tracker.Store.pause ();
Error backup_error = null;
- Data.backup_save (destination, null, error => {
+ var data_manager = Tracker.Main.get_data_manager ();
+ Data.backup_save (data_manager, destination, null, error => {
backup_error = error;
save.callback ();
});
diff --git a/tests/libtracker-data/tracker-backup-test.c b/tests/libtracker-data/tracker-backup-test.c
index f267217..8cf0d46 100644
--- a/tests/libtracker-data/tracker-backup-test.c
+++ b/tests/libtracker-data/tracker-backup-test.c
@@ -154,7 +154,8 @@ test_backup_and_restore_helper (const gchar *db_location,
backup_file = g_file_new_for_path (backup_filename);
g_free (backup_filename);
g_free (backup_location);
- tracker_data_backup_save (backup_file,
+ tracker_data_backup_save (manager,
+ backup_file,
data_location,
backup_finished_cb,
NULL,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]