[Evolution-hackers] [PATCH 2/6] Migrate sync_data from EBookBackendSqliteDB to EBookSqlite



We migrated the is_populated field, but not sync_data. EWS will need that.
---
 addressbook/libedata-book/e-book-sqlite.c | 24 ++++++++++++++++++++----
 addressbook/libedata-book/e-book-sqlite.h | 13 +++++++++++++
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/addressbook/libedata-book/e-book-sqlite.c b/addressbook/libedata-book/e-book-sqlite.c
index 9e5cb78..9131c09 100644
--- a/addressbook/libedata-book/e-book-sqlite.c
+++ b/addressbook/libedata-book/e-book-sqlite.c
@@ -2655,15 +2655,16 @@ ebsql_set_locale_internal (EBookSqlite *ebsql,
 
 /* Called with the lock held and inside a transaction */
 static gboolean
-ebsql_init_is_populated (EBookSqlite *ebsql,
-                         gint previous_schema,
-                         GError **error)
+ebsql_init_legacy_keys (EBookSqlite *ebsql,
+                        gint previous_schema,
+                        GError **error)
 {
        gboolean success = TRUE;
 
        /* Schema 8 is when we moved from EBookSqlite */
        if (previous_schema >= 1 && previous_schema < 8) {
                gint is_populated = 0;
+               gchar *sync_data = NULL;
 
                /* We need to hold on to the value of any previously set 'is_populated' flag */
                success = ebsql_exec_printf (
@@ -2681,6 +2682,21 @@ ebsql_init_is_populated (EBookSqlite *ebsql,
                                is_populated ? "1" : "0",
                                ebsql->priv->folderid);
                }
+
+               /* Repeat for 'sync_data' */
+               success = ebsql_exec_printf (
+                       ebsql, "SELECT sync_data FROM folders WHERE folder_id = %Q",
+                       get_string_cb, &sync_data, NULL, error, ebsql->priv->folderid);
+
+               if (success) {
+                       success = ebsql_exec_printf (
+                               ebsql, "INSERT or REPLACE INTO keys (key, value, folder_id) values (%Q, %Q, 
%Q)",
+                               NULL, NULL, NULL, error,
+                               E_BOOK_SQL_SYNC_DATA_KEY,
+                               sync_data, ebsql->priv->folderid);
+
+                       g_free (sync_data);
+               }
        }
 
        return success;
@@ -2902,7 +2918,7 @@ ebsql_new_internal (const gchar *path,
 
        /* When porting from older schemas, we need to port the old 'is-populated' flag */
        if (success)
-               success = ebsql_init_is_populated (ebsql, previous_schema, error);
+               success = ebsql_init_legacy_keys (ebsql, previous_schema, error);
 
        /* Load / resolve the current locale setting
         *
diff --git a/addressbook/libedata-book/e-book-sqlite.h b/addressbook/libedata-book/e-book-sqlite.h
index 67ba6ff..9aa1b3a 100644
--- a/addressbook/libedata-book/e-book-sqlite.h
+++ b/addressbook/libedata-book/e-book-sqlite.h
@@ -69,6 +69,19 @@
  **/
 #define E_BOOK_SQL_IS_POPULATED_KEY "eds-reserved-namespace-is-populated"
 
+/**
+ * E_BOOK_SQL_SYNC_DATA_KEY:
+ *
+ * This key can be used with e_book_sqlite_get_key_value().
+ *
+ * In the case of a migration from an older SQLite, any value which
+ * was previously stored with e_book_sqlitedb_set_sync_data()
+ * can be retrieved with this key.
+ *
+ * Since: 3.12
+ **/
+#define E_BOOK_SQL_SYNC_DATA_KEY "eds-reserved-namespace-sync-data"
+
 G_BEGIN_DECLS
 
 typedef struct _EBookSqlite EBookSqlite;
-- 
1.9.3


-- 
David Woodhouse                            Open Source Technology Centre
David Woodhouse intel com                              Intel Corporation

Attachment: smime.p7s
Description: S/MIME cryptographic signature



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