[epiphany/mcatanzaro/webapp-profile: 7/21] profile-migrator: Fix migrators maybe not running for default profile



commit b167327b1e23000174b265ad46528a3adf6ef0eb
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Sat Mar 16 12:40:39 2019 -0500

    profile-migrator: Fix migrators maybe not running for default profile
    
    Problem is, Epiphany creates the new profile dir with current migration
    version if it does not exist on startup, BEFORE running the migrator. So
    all migrators are guaranteed to never run if ~/.local/share/epiphany
    does not exist. This makes testing migration really hard.
    
    Still, this would probably not be a problem for most users, since they
    will have local storage and databases stored here already.

 src/profile-migrator/ephy-profile-migrator.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/src/profile-migrator/ephy-profile-migrator.c b/src/profile-migrator/ephy-profile-migrator.c
index 5778e2b2d..3fdacff0c 100644
--- a/src/profile-migrator/ephy-profile-migrator.c
+++ b/src/profile-migrator/ephy-profile-migrator.c
@@ -1282,6 +1282,7 @@ ephy_migrator (void)
 {
   int latest, i;
   EphyProfileMigrator m;
+  g_autofree char *legacy_migration_file = NULL;
 
   /* If after this point there's no profile dir, there's no point in
    * running anything because Epiphany has never run in this system, so
@@ -1305,8 +1306,11 @@ ephy_migrator (void)
     return TRUE;
   }
 
-  latest = MAX (ephy_profile_utils_get_migration_version (),
-                ephy_profile_utils_get_migration_version_for_profile_dir (legacy_profile_dir ()));
+  legacy_migration_file = g_build_filename (legacy_profile_dir (), ".migrated", NULL);
+  if (g_file_test (legacy_migration_file, G_FILE_TEST_EXISTS))
+    latest = ephy_profile_utils_get_migration_version_for_profile_dir (legacy_profile_dir ());
+  else
+    latest = ephy_profile_utils_get_migration_version ();
 
   LOG ("Running migrators up to version %d, current migration version is %d.",
        EPHY_PROFILE_MIGRATION_VERSION, latest);


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