[epiphany] ephy-profile-migrator: better safe than sorry in history migration



commit 38fd1803464eb2e4b84298fe323fac47f4af9ab0
Author: Xan Lopez <xan igalia com>
Date:   Tue May 8 18:35:45 2012 +0200

    ephy-profile-migrator: better safe than sorry in history migration
    
    Do nothing if the destination history file already exists.

 lib/ephy-profile-migrator.c |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)
---
diff --git a/lib/ephy-profile-migrator.c b/lib/ephy-profile-migrator.c
index 0558786..ac5e184 100644
--- a/lib/ephy-profile-migrator.c
+++ b/lib/ephy-profile-migrator.c
@@ -536,16 +536,6 @@ static GMarkupParser history_parse_funcs =
   NULL,
 };
 
-static EphyHistoryService *
-ensure_empty_history (const char* filename)
-{
-  if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
-    g_unlink (filename);
-  }
-
-  return ephy_history_service_new (filename);
-}
-
 static void
 migrate_history ()
 {
@@ -558,7 +548,15 @@ migrate_history ()
   HistoryParseData parse_data;
 
   gchar *temporary_file = g_build_filename (ephy_dot_dir (), "ephy-history.db", NULL);
-  history_service = ensure_empty_history (temporary_file);
+  /* Do nothing if the history file already exists. Safer than wiping
+   * it out. */
+  if (g_file_test (temporary_file, G_FILE_TEST_EXISTS)) {
+    g_warning ("Did not migrate Epiphany's history, the ephy-history.db file already exists");
+    g_free (temporary_file);
+    return;
+  }
+
+  history_service = ephy_history_service_new (temporary_file);
   g_free (temporary_file);
 
   memset (&parse_data, 0, sizeof (HistoryParseData));



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