Bug 1095231 - have migration of sync credentials do the right thing if no default profile exists. r=past

This commit is contained in:
Mark Hammond 2014-11-07 20:04:26 +11:00
parent f8c8e1a738
commit 62ca404238

View File

@ -383,13 +383,19 @@ function show(id, childId) {
// Migrate sync data from the default profile to the dev-edition profile. // Migrate sync data from the default profile to the dev-edition profile.
function migrateToDevEdition(user, urlParams) { function migrateToDevEdition(user, urlParams) {
let migrateSyncCreds = false; let defaultProfilePath;
try { try {
migrateSyncCreds = Services.prefs.getBoolPref("identity.fxaccounts.migrateToDevEdition"); defaultProfilePath = window.getDefaultProfilePath();
} catch (e) {} } catch (e) {} // no default profile.
let migrateSyncCreds = false;
if (defaultProfilePath) {
try {
migrateSyncCreds = Services.prefs.getBoolPref("identity.fxaccounts.migrateToDevEdition");
} catch (e) {}
}
if (migrateSyncCreds) { if (migrateSyncCreds) {
Cu.import("resource://gre/modules/osfile.jsm"); Cu.import("resource://gre/modules/osfile.jsm");
let fxAccountsStorage = OS.Path.join(window.getDefaultProfilePath(), fxAccountsCommon.DEFAULT_STORAGE_FILENAME); let fxAccountsStorage = OS.Path.join(defaultProfilePath, fxAccountsCommon.DEFAULT_STORAGE_FILENAME);
return OS.File.read(fxAccountsStorage, { encoding: "utf-8" }).then(text => { return OS.File.read(fxAccountsStorage, { encoding: "utf-8" }).then(text => {
let accountData = JSON.parse(text).accountData; let accountData = JSON.parse(text).accountData;
return fxAccounts.setSignedInUser(accountData); return fxAccounts.setSignedInUser(accountData);