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



commit 343ee0941f1453774cf1311702558ca64b8569e1
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 14d376e14..6cd788f00 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]