[epiphany/profile-migrator-diego: 7/12] e-profile-migrator: update new_urls_table



commit 40f1c63d13818eeaa6ab8b25d83fb06530ceb900
Author: Diego Escalante Urrelo <diegoe igalia com>
Date:   Mon Sep 3 04:49:44 2012 -0500

    e-profile-migrator: update new_urls_table

 lib/ephy-profile-migrator.c |   41 +++++++++++++++++++++++++++++------------
 1 files changed, 29 insertions(+), 12 deletions(-)
---
diff --git a/lib/ephy-profile-migrator.c b/lib/ephy-profile-migrator.c
index 1cb6f11..a3b6518 100644
--- a/lib/ephy-profile-migrator.c
+++ b/lib/ephy-profile-migrator.c
@@ -870,14 +870,17 @@ migrate_web_app_links ()
   ephy_web_application_free_application_list (apps);
 }
 
-static void
-migrate_new_urls_table ()
+static gboolean
+migrate_new_urls_table (const char *profile_dir,
+                        const char *dest_dir,
+                        gboolean dry_run,
+                        gpointer data)
 {
   EphySQLiteConnection *history_database;
   char *filename;
   GError *error = NULL;
 
-  filename = g_build_filename (ephy_dot_dir (), "ephy-history.db", NULL);
+  filename = g_build_filename (profile_dir, "ephy-history.db", NULL);
   history_database = ephy_sqlite_connection_new ();
   ephy_sqlite_connection_open (history_database, filename, &error);
 
@@ -885,32 +888,46 @@ migrate_new_urls_table ()
     g_warning ("Failed to open history database: %s\n", error->message);
     g_error_free (error);
     g_free (filename);
-    return;
+
+    return FALSE;
   }
 
-  ephy_sqlite_connection_execute (history_database,
-                                  "ALTER TABLE urls "
-                                  "ADD COLUMN thumbnail_update_time INTEGER DEFAULT 0",
-                                  &error);
+  if (dry_run)
+    LOG ("[urls_table] DR: Adding thumbnail_update_time column to %s", filename);
+  else
+    ephy_sqlite_connection_execute (history_database,
+                                    "ALTER TABLE urls "
+                                    "ADD COLUMN thumbnail_update_time INTEGER DEFAULT 0",
+                                    &error);
   if (error) {
     g_warning ("Failed to add new column to table in history backend: %s\n",
                error->message);
     g_error_free (error);
     error = NULL;
+
+    return FALSE;
   }
-  ephy_sqlite_connection_execute (history_database,
-                                  "ALTER TABLE urls "
-                                  "ADD COLUMN hidden_from_overview INTEGER DEFAULT 0",
-                                  &error);
+
+  if (dry_run)
+    LOG ("[urls_table] DR: Adding hidden_from_overview column to %s", filename);
+  else
+    ephy_sqlite_connection_execute (history_database,
+                                    "ALTER TABLE urls "
+                                    "ADD COLUMN hidden_from_overview INTEGER DEFAULT 0",
+                                    &error);
   if (error) {
     g_warning ("Failed to add new column to table in history backend: %s\n",
                error->message);
     g_error_free (error);
     error = NULL;
+
+    return FALSE;
   }
 
   g_object_unref (history_database);
   g_free (filename);
+
+  return TRUE;
 }
 
 const EphyProfileMigrator migrators[] = {



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