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.
function migrateToDevEdition(user, urlParams) {
let defaultProfilePath;
try {
defaultProfilePath = window.getDefaultProfilePath();
} catch (e) {} // no default profile.
let migrateSyncCreds = false;
if (defaultProfilePath) {
try {
migrateSyncCreds = Services.prefs.getBoolPref("identity.fxaccounts.migrateToDevEdition");
} catch (e) {}
}
if (migrateSyncCreds) {
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 => {
let accountData = JSON.parse(text).accountData;
return fxAccounts.setSignedInUser(accountData);