[tracker/wip/sam/private-store: 2/3] libtracker-data: WIP: allow opening stores in different places



commit 9faae9ce5c852a744644b18b7bcef88b5491c397
Author: Sam Thursfield <sam afuera me uk>
Date:   Thu Jun 23 23:35:53 2016 +0100

    libtracker-data: WIP: allow opening stores in different places
    
    These 'private' store can optionally use a custom sets of ontologies.
    
    This can be used to allow applications and test-cases to keep a private
    Tracker store, to avoid messing up the user's real data, or to allow
    experimenting with different ontologies.
    
    Still to do ...
            * make it work !
            * make the tests that currently override XDG env vars use this
              method instead

 src/libtracker-data/libtracker-data.vapi   |    4 +-
 src/libtracker-data/tracker-data-backup.c  |   13 ++++++-----
 src/libtracker-data/tracker-data-backup.h  |    5 ++-
 src/libtracker-data/tracker-data-manager.c |   32 ++++++++++++++++++---------
 src/libtracker-data/tracker-data-manager.h |    5 ++-
 src/libtracker-data/tracker-db-manager.c   |    4 ++-
 src/libtracker-data/tracker-db-manager.h   |    4 ++-
 7 files changed, 42 insertions(+), 25 deletions(-)
---
diff --git a/src/libtracker-data/libtracker-data.vapi b/src/libtracker-data/libtracker-data.vapi
index 65ca605..91d334d 100644
--- a/src/libtracker-data/libtracker-data.vapi
+++ b/src/libtracker-data/libtracker-data.vapi
@@ -222,12 +222,12 @@ namespace Tracker {
                public delegate void BackupFinished (GLib.Error error);
 
                public void backup_save (GLib.File destination, owned BackupFinished callback);
-               public void backup_restore (GLib.File journal, [CCode (array_length = false)] string[]? 
test_schema, BusyCallback busy_callback) throws GLib.Error;
+               public void backup_restore (string store_path, [CCode (array_length = false)] string[]? 
ontologies, GLib.File journal, BusyCallback busy_callback) throws GLib.Error;
        }
 
        [CCode (cheader_filename = "libtracker-data/tracker-data-manager.h")]
        namespace Data.Manager {
-               public bool init (DBManagerFlags flags, [CCode (array_length = false)] string[]? test_schema, 
out bool first_time, bool journal_check, bool restoring_backup, uint select_cache_size, uint 
update_cache_size, BusyCallback? busy_callback, string? busy_status) throws DBInterfaceError, DBJournalError;
+               public bool init (string store_path, [CCode (array_length = false)] string[]? ontologies, 
DBManagerFlags flags, out bool first_time, bool journal_check, bool restoring_backup, uint select_cache_size, 
uint update_cache_size, BusyCallback? busy_callback, string? busy_status) throws DBInterfaceError, 
DBJournalError;
                public void shutdown ();
        }
 
diff --git a/src/libtracker-data/tracker-data-backup.c b/src/libtracker-data/tracker-data-backup.c
index 1d6d4b9..5abe845 100644
--- a/src/libtracker-data/tracker-data-backup.c
+++ b/src/libtracker-data/tracker-data-backup.c
@@ -549,8 +549,9 @@ tracker_data_backup_save (GFile                     *destination,
 }
 
 void
-tracker_data_backup_restore (GFile                *journal,
-                             const gchar         **test_schemas,
+tracker_data_backup_restore (const gchar          *store_path,
+                             const gchar         **ontologies,
+                             GFile                *journal,
                              TrackerBusyCallback   busy_callback,
                              gpointer              busy_user_data,
                              GError              **error)
@@ -689,8 +690,8 @@ tracker_data_backup_restore (GFile                *journal,
                }
 #endif /* DISABLE_JOURNAL */
 
-               tracker_data_manager_init (flags, test_schemas, &is_first, TRUE, TRUE,
-                                          select_cache_size, update_cache_size,
+               tracker_data_manager_init (store_path, ontologies, flags, &is_first, TRUE,
+                                          TRUE, select_cache_size, update_cache_size,
                                           busy_callback, busy_user_data,
                                           "Restoring backup", &internal_error);
 
@@ -698,8 +699,8 @@ tracker_data_backup_restore (GFile                *journal,
                if (internal_error) {
                        restore_from_temp ();
 
-                       tracker_data_manager_init (flags, test_schemas, &is_first, TRUE, TRUE,
-                                                  select_cache_size, update_cache_size,
+                       tracker_data_manager_init (store_path, ontologies, flags, &is_first, TRUE,
+                                                  TRUE, select_cache_size, update_cache_size,
                                                   busy_callback, busy_user_data,
                                                   "Restoring backup", &internal_error);
                } else {
diff --git a/src/libtracker-data/tracker-data-backup.h b/src/libtracker-data/tracker-data-backup.h
index 92c0a4c..c47edd9 100644
--- a/src/libtracker-data/tracker-data-backup.h
+++ b/src/libtracker-data/tracker-data-backup.h
@@ -47,8 +47,9 @@ void   tracker_data_backup_save        (GFile                     *destination,
                                         TrackerDataBackupFinished  callback,
                                         gpointer                   user_data,
                                         GDestroyNotify             destroy);
-void   tracker_data_backup_restore     (GFile                     *journal,
-                                        const gchar              **test_schema,
+void   tracker_data_backup_restore     (const gchar               *store_path,
+                                        const gchar              **ontologies,
+                                        GFile                     *journal,
                                         TrackerBusyCallback        busy_callback,
                                         gpointer                   busy_user_data,
                                         GError                   **error);
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 5a811bd..ebc1d66 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -3536,8 +3536,9 @@ tracker_data_manager_reload (TrackerBusyCallback   busy_callback,
        g_message ("  Data manager shut down, now initializing again...");
 
        /* And initialize it again, this actually triggers index recreation. */
-       status = tracker_data_manager_init (flags,
-                                           NULL,
+       status = tracker_data_manager_init (NULL,  /* FIXME: should pass the store path ! */
+                                           NULL,  /* FIXME: should pass the same ontologies as before? no ? 
*/
+                                           flags,
                                            &is_first,
                                            TRUE,
                                            FALSE,
@@ -3673,8 +3674,9 @@ tracker_data_manager_init_fts (TrackerDBInterface *iface,
 }
 
 gboolean
-tracker_data_manager_init (TrackerDBManagerFlags   flags,
-                           const gchar           **test_schemas,
+tracker_data_manager_init (const gchar            *store_path,
+                           const gchar           **ontologies,
+                           TrackerDBManagerFlags   flags,
                            gboolean               *first_time,
                            gboolean                journal_check,
                            gboolean                restoring_backup,
@@ -3701,6 +3703,9 @@ tracker_data_manager_init (TrackerDBManagerFlags   flags,
        gboolean read_journal;
 #endif
 
+       /* FIXME: JUST TO FIX COMPILE */
+       char **test_schemas;
+
        read_only = (flags & TRACKER_DB_MANAGER_READONLY) ? TRUE : FALSE;
 
        tracker_data_update_init ();
@@ -3731,7 +3736,9 @@ tracker_data_manager_init (TrackerDBManagerFlags   flags,
        read_journal = FALSE;
 #endif
 
-       if (!tracker_db_manager_init (flags,
+       if (!tracker_db_manager_init (store_path,
+                                     ontologies,
+                                     flags,
                                      &is_first_time_index,
                                      restoring_backup,
                                      FALSE,
@@ -4262,8 +4269,9 @@ tracker_data_manager_init (TrackerDBManagerFlags   flags,
                                                /* This also does tracker_locale_shutdown */
                                                tracker_data_manager_shutdown ();
 
-                                               return tracker_data_manager_init (flags | 
TRACKER_DB_MANAGER_DO_NOT_CHECK_ONTOLOGY,
-                                                                                 test_schemas,
+                                               return tracker_data_manager_init (store_path,
+                                                                                 ontologies,
+                                                                                 flags | 
TRACKER_DB_MANAGER_DO_NOT_CHECK_ONTOLOGY,
                                                                                  first_time,
                                                                                  journal_check,
                                                                                  restoring_backup,
@@ -4352,8 +4360,9 @@ tracker_data_manager_init (TrackerDBManagerFlags   flags,
                                        /* This also does tracker_locale_shutdown */
                                        tracker_data_manager_shutdown ();
 
-                                       return tracker_data_manager_init (flags | 
TRACKER_DB_MANAGER_DO_NOT_CHECK_ONTOLOGY,
-                                                                         test_schemas,
+                                       return tracker_data_manager_init (store_path,
+                                                                         ontologies,
+                                                                         flags | 
TRACKER_DB_MANAGER_DO_NOT_CHECK_ONTOLOGY,
                                                                          first_time,
                                                                          journal_check,
                                                                          restoring_backup,
@@ -4459,8 +4468,9 @@ tracker_data_manager_init (TrackerDBManagerFlags   flags,
                                /* This also does tracker_locale_shutdown */
                                tracker_data_manager_shutdown ();
 
-                               return tracker_data_manager_init (flags | 
TRACKER_DB_MANAGER_DO_NOT_CHECK_ONTOLOGY,
-                                                                 test_schemas,
+                               return tracker_data_manager_init (store_path,
+                                                                 ontologies,
+                                                                 flags | 
TRACKER_DB_MANAGER_DO_NOT_CHECK_ONTOLOGY,
                                                                  first_time,
                                                                  journal_check,
                                                                  restoring_backup,
diff --git a/src/libtracker-data/tracker-data-manager.h b/src/libtracker-data/tracker-data-manager.h
index 4ffecca..40eda80 100644
--- a/src/libtracker-data/tracker-data-manager.h
+++ b/src/libtracker-data/tracker-data-manager.h
@@ -45,8 +45,9 @@ typedef enum {
 } TrackerDataOntologyError;
 
 GQuark   tracker_data_ontology_error_quark           (void);
-gboolean tracker_data_manager_init                   (TrackerDBManagerFlags   flags,
-                                                      const gchar           **test_schema,
+gboolean tracker_data_manager_init                   (const gchar            *store_path,
+                                                      const gchar           **ontologies,
+                                                      TrackerDBManagerFlags   flags,
                                                       gboolean               *first_time,
                                                       gboolean                journal_check,
                                                       gboolean                restoring_backup,
diff --git a/src/libtracker-data/tracker-db-manager.c b/src/libtracker-data/tracker-db-manager.c
index ef7d762..507fa4d 100644
--- a/src/libtracker-data/tracker-db-manager.c
+++ b/src/libtracker-data/tracker-db-manager.c
@@ -845,7 +845,9 @@ perform_recreate (gboolean *first_time, GError **error)
 }
 
 gboolean
-tracker_db_manager_init (TrackerDBManagerFlags   flags,
+tracker_db_manager_init (const gchar            *store_path,
+                         const gchar           **ontologies,
+                         TrackerDBManagerFlags   flags,
                          gboolean               *first_time,
                          gboolean                restoring_backup,
                          gboolean                shared_cache,
diff --git a/src/libtracker-data/tracker-db-manager.h b/src/libtracker-data/tracker-db-manager.h
index c88c7b4..a550132 100644
--- a/src/libtracker-data/tracker-db-manager.h
+++ b/src/libtracker-data/tracker-db-manager.h
@@ -51,7 +51,9 @@ typedef enum {
 } TrackerDBManagerFlags;
 
 GType               tracker_db_get_type                       (void) G_GNUC_CONST;
-gboolean            tracker_db_manager_init                   (TrackerDBManagerFlags   flags,
+gboolean            tracker_db_manager_init                   (const gchar            *store_path,
+                                                               const gchar           **ontologies,
+                                                               TrackerDBManagerFlags   flags,
                                                                gboolean               *first_time,
                                                                gboolean                restoring_backup,
                                                                gboolean                shared_cache,


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