[epiphany] profile-utils: do not spawn the profile migrator unnecessarily



commit 709193be3080f3f5067f714f2d6124f90ff6c073
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Thu Feb 13 14:33:57 2014 +0200

    profile-utils: do not spawn the profile migrator unnecessarily
    
    Spare some cycles by not spawning the profile migrator if there
    is nothing to migrate.

 lib/ephy-profile-utils.c |    6 ++++++
 src/ephy-main.c          |   22 +++++++++++-----------
 2 files changed, 17 insertions(+), 11 deletions(-)
---
diff --git a/lib/ephy-profile-utils.c b/lib/ephy-profile-utils.c
index 5d295e5..78ced32 100644
--- a/lib/ephy-profile-utils.c
+++ b/lib/ephy-profile-utils.c
@@ -105,6 +105,12 @@ ephy_profile_utils_do_migration (const char *profile_directory, int test_to_run,
 
   argv[i++] = version = g_strdup_printf ("%d", EPHY_PROFILE_MIGRATION_VERSION);
 
+  /* If we're not trying to run a migration step in a test and there
+     is nothing to migrate, don't spawn the migrator at all. */
+  if (test_to_run == -1 &&
+      EPHY_PROFILE_MIGRATION_VERSION == ephy_profile_utils_get_migration_version ())
+    return TRUE;
+
   if (test_to_run != -1) {
     index = g_strdup_printf ("%d", test_to_run);
 
diff --git a/src/ephy-main.c b/src/ephy-main.c
index d10f4c5..12704ea 100644
--- a/src/ephy-main.c
+++ b/src/ephy-main.c
@@ -358,17 +358,6 @@ main (int argc,
     exit (1);
   }
 
-  /* Run the migration in all cases, except when running a private
-     instance without a given profile directory or running in
-     incognito mode. */
-  if (!(private_instance && profile_directory == NULL) && incognito_mode == FALSE) {
-    /* If the migration fails we don't really want to continue. */
-    if (!ephy_profile_utils_do_migration ((const char *)profile_directory, -1, FALSE)) {
-      g_print ("Failed to run the migrator process, Web will now abort.");
-      exit (1);
-    }
-  }
-
   /* Start our services */
   flags = EPHY_FILE_HELPERS_ENSURE_EXISTS;
 
@@ -385,6 +374,17 @@ main (int argc,
     exit (1);
   }
 
+  /* Run the migration in all cases, except when running a private
+     instance without a given profile directory or running in
+     incognito mode. */
+  if (!(private_instance && profile_directory == NULL) && incognito_mode == FALSE) {
+    /* If the migration fails we don't really want to continue. */
+    if (!ephy_profile_utils_do_migration ((const char *)profile_directory, -1, FALSE)) {
+      g_print ("Failed to run the migrator process, Web will now abort.");
+      exit (1);
+    }
+  }
+
   arbitrary_url = g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
                                           EPHY_PREFS_LOCKDOWN_ARBITRARY_URL);
 


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