Bug 717070 - Profile reset - Part 2 - migrator portion. r=mano

This commit is contained in:
Matthew Noorenberghe 2012-02-23 19:34:18 -08:00
parent 682f579aec
commit 42e63f9aed
2 changed files with 19 additions and 1 deletions

View File

@ -65,6 +65,7 @@ var MigrationWizard = {
this._source = window.arguments[0];
this._migrator = window.arguments[1].QueryInterface(kIMig);
this._autoMigrate = window.arguments[2].QueryInterface(kIPStartup);
this._skipImportSourcePage = window.arguments[3];
if (this._autoMigrate) {
// Show the "nothing" option in the automigrate case to provide an
@ -94,7 +95,7 @@ var MigrationWizard = {
// Reference to the "From File" radio button
var fromfile = null;
//XXXquark This function is called before init, so check for bookmarks here
// init is not called when openDialog opens the wizard, so check for bookmarks here.
if ("arguments" in window && window.arguments[0] == "bookmarks") {
this._bookmarks = true;
@ -151,6 +152,12 @@ var MigrationWizard = {
document.getElementById("importBookmarks").hidden = true;
document.getElementById("importAll").hidden = true;
}
// Advance to the next page if the caller told us to.
if (this._migrator && this._skipImportSourcePage) {
this._wiz.advance();
this._wiz.canRewind = false;
}
},
onImportSourcePageAdvanced: function ()

View File

@ -227,6 +227,12 @@ FirefoxProfileMigrator.prototype = {
this._replaceBookmarks = true;
}
// Ensure that aProfile is not the current profile.
if (this._paths.currentProfile.path === this._sourceProfile.path) {
throw new Exception("Source and destination profiles are the same");
return;
}
Services.obs.notifyObservers(null, "Migration:Started", null);
// Reset pending count. If this count becomes 0, "Migration:Ended"
@ -278,6 +284,11 @@ FirefoxProfileMigrator.prototype = {
this._sourceProfile.initWithPath(aProfile);
let result = 0;
// Ensure that aProfile is not the current profile.
if (this._paths.currentProfile.path === this._sourceProfile.path)
return result;
if (!this._sourceProfile.exists() || !this._sourceProfile.isReadable()) {
Cu.reportError("source profile directory doesn't exist or is not readable");
return result;