[epiphany/gnome-3-26] profile-migrator: Handle double bookmark timestamp migration



commit a81436a80d3a1010f697d1201110eb5fc64c317e
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Mon Jan 22 12:38:36 2018 -0600

    profile-migrator: Handle double bookmark timestamp migration
    
    It's common for developers to run the profile migrator several times in
    a row. Migrators should be robust to this. We need to ensure the
    GVariant format is really the old format before using it in the
    timestamp migration.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=792683

 src/profile-migrator/ephy-profile-migrator.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/profile-migrator/ephy-profile-migrator.c b/src/profile-migrator/ephy-profile-migrator.c
index 7fda9a9..6be0a89 100644
--- a/src/profile-migrator/ephy-profile-migrator.c
+++ b/src/profile-migrator/ephy-profile-migrator.c
@@ -1326,6 +1326,9 @@ convert_bookmark_timestamp (GVariant *value)
   const char *id;
   char *tag;
 
+  if (!g_variant_check_format_string (value, "(x&s&sdbas)", FALSE))
+    return NULL;
+
   g_variant_get (value, "(x&s&sdbas)",
                  &time_added, &title, &id,
                  &timestamp_d, &is_uploaded, &iter);
@@ -1396,9 +1399,14 @@ migrate_bookmarks_timestamp (void)
   for (int i = 0; i < length; i++) {
     GVariant *value = gvdb_table_get_value (bookmarks_table_in, urls[i]);
     GVariant *new_value = convert_bookmark_timestamp (value);
-    GvdbItem *item = gvdb_hash_table_insert (bookmarks_table_out, urls[i]);
-    gvdb_item_set_value (item, new_value);
+    if (new_value != NULL) {
+      GvdbItem *item = gvdb_hash_table_insert (bookmarks_table_out, urls[i]);
+      gvdb_item_set_value (item, new_value);
+    }
     g_variant_unref (value);
+
+    if (new_value == NULL)
+      goto out;
   }
 
   gvdb_table_write_contents (root_table_out, filename, FALSE, NULL);


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