[epiphany] Fix bookmarks migration



commit 86fd75de53ba32726e46a3409e0ec2465e6e0181
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Mon Nov 21 12:23:53 2016 +0100

    Fix bookmarks migration
    
    EphyBookmarksManager always creates an empty bookmarks.gvdb on its init
    method, and migrate_bookmarks() checks whether bookmarks.gvdb already
    exists to avoid migrating the bookmarks twice. Since migrate_bookmarks()
    creates the EphyBookmarksManager before checking for bookmarks.gvdb, it
    always exists and bookmarks are never migrated. This is a regression
    introduced in commit 54006df8dba31a5a58686e7d2473d64f3e454683.
    This patch creates the manager after the initial checks, so that we also
    avoid creating the manager and all the sync IO involved if we are not
    going to use it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=774785

 src/profile-migrator/ephy-profile-migrator.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/src/profile-migrator/ephy-profile-migrator.c b/src/profile-migrator/ephy-profile-migrator.c
index c4f387b..137394e 100644
--- a/src/profile-migrator/ephy-profile-migrator.c
+++ b/src/profile-migrator/ephy-profile-migrator.c
@@ -548,7 +548,7 @@ parse_rdf_item (EphyBookmarksManager *manager,
 static void
 migrate_bookmarks (void)
 {
-  EphyBookmarksManager *manager = ephy_bookmarks_manager_new ();
+  EphyBookmarksManager *manager;
   char *filename;
   xmlDocPtr doc;
   xmlNodePtr child;
@@ -558,23 +558,29 @@ migrate_bookmarks (void)
                                EPHY_BOOKMARKS_FILE,
                                NULL);
 
-  if (g_file_test (filename, G_FILE_TEST_EXISTS) == TRUE)
-    goto out;
+  if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
+    g_free (filename);
+    return;
+  }
 
   g_free (filename);
   filename = g_build_filename (ephy_dot_dir (),
                                "bookmarks.rdf",
                                NULL);
 
-  if (g_file_test (filename, G_FILE_TEST_EXISTS) == FALSE)
-    goto out;
+  if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
+    g_free (filename);
+    return;
+  }
 
   doc = xmlParseFile (filename);
+  g_free (filename);
   if (doc == NULL) {
     g_warning ("Failed to re-import the bookmarks. All bookmarks lost!\n");
-    goto out;
+    return;
   }
 
+  manager = ephy_bookmarks_manager_new ();
   root = xmlDocGetRootElement (doc);
 
   child = root->children;
@@ -593,8 +599,6 @@ migrate_bookmarks (void)
                                              NULL);
 
   xmlFreeDoc (doc);
-out:
-  g_free (filename);
   g_object_unref (manager);
 }
 


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