[epiphany] ephy-profile-migrator: allow running migration in non-default profile directories



commit 1afb0171665b4234ceb57f073a0834b6dc3e005d
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Mon Sep 3 17:33:47 2012 +0300

    ephy-profile-migrator: allow running migration in non-default profile directories
    
    This is necessary since we add new columns to the history database in
    step 8 of migration. However, non-default profile directories don't
    have a .migrated file right now but, since up to step 7 it was
    possible to use these profiles without migration, it is safe to assume
    that a non-default profile without a .migrated file can be migrated
    starting from step 8.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=681679

 lib/ephy-profile-migrator.c |   10 +++++++++-
 lib/ephy-profile-utils.c    |    8 ++++++++
 2 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/lib/ephy-profile-migrator.c b/lib/ephy-profile-migrator.c
index 0f4d499..9acafd7 100644
--- a/lib/ephy-profile-migrator.c
+++ b/lib/ephy-profile-migrator.c
@@ -53,6 +53,7 @@
 
 static int do_step_n = -1;
 static int version = -1;
+static char *profile_dir = NULL;
 
 /*
  * What to do to add new migration steps:
@@ -889,6 +890,8 @@ static const GOptionEntry option_entries[] =
     N_("Executes only the n-th migration step"), NULL },
   { "version", 'v', 0, G_OPTION_ARG_INT, &version,
     N_("Specifies the required version for the migrator"), NULL },
+  { "profile-dir", 'p', 0, G_OPTION_ARG_FILENAME, &profile_dir,
+    N_("Specifies the profile where the migrator should run"), NULL },
   { NULL }
 };
 
@@ -898,6 +901,7 @@ main (int argc, char *argv[])
   GOptionContext *option_context;
   GOptionGroup *option_group;
   GError *error = NULL;
+  EphyFileHelpersFlags file_helpers_flags = EPHY_FILE_HELPERS_NONE;
 
   g_type_init ();
 
@@ -930,7 +934,11 @@ main (int argc, char *argv[])
 
   ephy_debug_init ();
 
-  if (!ephy_file_helpers_init (NULL, EPHY_FILE_HELPERS_NONE, NULL)) {
+  if (profile_dir != NULL)
+    file_helpers_flags = EPHY_FILE_HELPERS_PRIVATE_PROFILE |
+      EPHY_FILE_HELPERS_KEEP_DIR;
+
+  if (!ephy_file_helpers_init (profile_dir, file_helpers_flags, NULL)) {
     LOG ("Something wrong happened with ephy_file_helpers_init()");
     return -1;
   }
diff --git a/lib/ephy-profile-utils.c b/lib/ephy-profile-utils.c
index 829d689..58abfff 100644
--- a/lib/ephy-profile-utils.c
+++ b/lib/ephy-profile-utils.c
@@ -51,6 +51,14 @@ ephy_profile_utils_get_migration_version ()
 
     if (result != 1)
       latest = 0;
+  } else if (ephy_dot_dir_is_default () == FALSE) {
+    /* Since version 8, we need to migrate also profile directories
+       other than the default one. Profiles in such directories work
+       perfectly fine without going through the first 7 migration
+       steps, so it is safe to assume that any non-default profile
+       directory without a migration file can be migrated starting
+       from the step 8. */
+    latest = 7;
   }
 
   g_free (migrated_file);



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