Bug 1283267 - Save start time of automigration when we save the finished time, to ensure both actually get written to prefs. r=dolske, a=lizzard
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 29 Jun 2016 20:59:23 +0100
changeset 342460 49071ecbfedbffba445e4f26cd5891c2b8e14968
parent 342459 51f3ece19e7bc06f58c57a4bfb2810ad0e1669d9
child 342461 efd321bddf46bfe6da2881398f9311c1b898ed31
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske, lizzard
bugs1283267
milestone49.0
Bug 1283267 - Save start time of automigration when we save the finished time, to ensure both actually get written to prefs. r=dolske, a=lizzard MozReview-Commit-ID: J4foRyWlJTv
browser/components/migration/AutoMigrate.jsm
--- a/browser/components/migration/AutoMigrate.jsm
+++ b/browser/components/migration/AutoMigrate.jsm
@@ -51,23 +51,26 @@ const AutoMigrate = {
         sawErrors = true;
       } else if (topic == "Migration:Ended") {
         histogram.add(25);
         if (sawErrors) {
           histogram.add(26);
         }
         Services.obs.removeObserver(migrationObserver, "Migration:Ended");
         Services.obs.removeObserver(migrationObserver, "Migration:ItemError");
+        Services.prefs.setCharPref(kAutoMigrateStartedPref, startTime.toString());
         Services.prefs.setCharPref(kAutoMigrateFinishedPref, Date.now().toString());
       }
     };
 
     Services.obs.addObserver(migrationObserver, "Migration:Ended", false);
     Services.obs.addObserver(migrationObserver, "Migration:ItemError", false);
-    Services.prefs.setCharPref(kAutoMigrateStartedPref, Date.now().toString());
+    // We'll save this when the migration has finished, at which point the pref
+    // service will be available.
+    let startTime = Date.now();
     migrator.migrate(this.resourceTypesToUse, profileStartup, profileToMigrate);
     histogram.add(20);
   },
 
   /**
    * Pick and return a migrator to use for automatically migrating.
    *
    * @param {String} migratorKey   optional, a migrator key to prefer/pick.