[evolution-data-server] Bug 735523 - Migrate sync_data from EBookBackendSqliteDB to EBookSqlite



commit 52c1ab355f3d28bce8aed7259fa276665cd9bf0b
Author: David Woodhouse <David Woodhouse intel com>
Date:   Sat Aug 23 10:05:06 2014 -0500

    Bug 735523 - 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 c28497a..c5da9ce 100644
--- a/addressbook/libedata-book/e-book-sqlite.c
+++ b/addressbook/libedata-book/e-book-sqlite.c
@@ -2665,15 +2665,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 (
@@ -2691,6 +2692,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;
@@ -2917,7 +2933,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 0897095..41c9a61 100644
--- a/addressbook/libedata-book/e-book-sqlite.h
+++ b/addressbook/libedata-book/e-book-sqlite.h
@@ -68,6 +68,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;


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