summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2017-11-18 14:59:14 +0100
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2017-11-18 14:59:14 +0100
commitc40ee8c608e895763ae7004a5d5fb3c0df0e3f39 (patch)
treeff3590a47a668989b351277f858ec9588ad308d0
parent7a6b077e4eff356c99b2d917c3dc0c4f42f8e10d (diff)
downloadpalemoon-gre-c40ee8c608e895763ae7004a5d5fb3c0df0e3f39.tar.gz
Profiles - the refresh - migrate (passwords)
-rw-r--r--browser/components/migration/FirefoxProfileMigrator.js18
-rw-r--r--toolkit/xre/nsAppRunner.cpp41
2 files changed, 35 insertions, 24 deletions
diff --git a/browser/components/migration/FirefoxProfileMigrator.js b/browser/components/migration/FirefoxProfileMigrator.js
index c7b353dae..ab4ae55fb 100644
--- a/browser/components/migration/FirefoxProfileMigrator.js
+++ b/browser/components/migration/FirefoxProfileMigrator.js
@@ -73,12 +73,12 @@ FirefoxProfileMigrator.prototype.getResources = function(aProfile) {
let file = sourceProfileDir.clone();
file.append(fileName);
- // File resources are monolithic. We don't make partial copies since
- // they are not expected to work alone.
- if (!file.exists())
- return null;
-
- files.push(file);
+ if (file.exists()) {
+ files.push(file);
+ }
+ }
+ if (!files.length) {
+ return null;
}
return {
type: aMigrationType,
@@ -92,10 +92,10 @@ FirefoxProfileMigrator.prototype.getResources = function(aProfile) {
};
let types = MigrationUtils.resourceTypes;
- let places = getFileResource(types.HISTORY, ["places.sqlite"]);
- let cookies = getFileResource(types.COOKIES, ["cookies.sqlite"]);
+ let places = getFileResource(types.HISTORY, ["places.sqlite", "places.sqlite-wal"]);
+ let cookies = getFileResource(types.COOKIES, ["cookies.sqlite", "cookies.sqlite-wal"]);
let passwords = getFileResource(types.PASSWORDS,
- ["signons.sqlite", "key3.db"]);
+ ["signons.sqlite", "logins.json", "key3.db"]);
let formData = getFileResource(types.FORMDATA, ["formhistory.sqlite"]);
let bookmarksBackups = getFileResource(types.OTHERDATA,
[PlacesBackups.profileRelativeFolderPath]);
diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp
index 6cd1773da..7156ff5bc 100644
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -1879,17 +1879,19 @@ ShowProfileManager(nsIToolkitProfileService* aProfileSvc,
}
/**
- * Set the currently running profile as the default/selected one.
+ * Get the currently running profile using its root directory.
*
+ * @param aProfileSvc The profile service
* @param aCurrentProfileRoot The root directory of the current profile.
- * @return an error if aCurrentProfileRoot is not found or the profile could not
- * be set as the default.
+ * @param aProfile Out-param that returns the profile object.
+ * @return an error if aCurrentProfileRoot is not found
*/
static nsresult
-SetCurrentProfileAsDefault(nsIToolkitProfileService* aProfileSvc,
- nsIFile* aCurrentProfileRoot)
+GetCurrentProfile(nsIToolkitProfileService* aProfileSvc,
+ nsIFile* aCurrentProfileRoot,
+ nsIToolkitProfile** aProfile)
{
- NS_ENSURE_ARG_POINTER(aProfileSvc);
+ NS_ENSURE_ARG_POINTER(aProfile);
nsCOMPtr<nsISimpleEnumerator> profiles;
nsresult rv = aProfileSvc->GetProfiles(getter_AddRefs(profiles));
@@ -1905,7 +1907,8 @@ SetCurrentProfileAsDefault(nsIToolkitProfileService* aProfileSvc,
profile->GetRootDir(getter_AddRefs(profileRoot));
profileRoot->Equals(aCurrentProfileRoot, &foundMatchingProfile);
if (foundMatchingProfile) {
- return aProfileSvc->SetSelectedProfile(profile);
+ profile.forget(aProfile);
+ return NS_OK;
}
rv = profiles->GetNext(getter_AddRefs(supports));
}
@@ -3599,15 +3602,23 @@ XREMain::XRE_mainRun()
nsresult backupCreated = ProfileResetCleanup(profileBeingReset);
if (NS_FAILED(backupCreated)) NS_WARNING("Could not cleanup the profile that was reset");
- // Set the new profile as the default after we're done cleaning up the old profile,
- // iff that profile was already the default
- if (profileWasSelected) {
- // this is actually "broken" - see bug 1122124
- rv = SetCurrentProfileAsDefault(mProfileSvc, mProfD);
- if (NS_FAILED(rv)) NS_WARNING("Could not set current profile as the default");
+ nsCOMPtr<nsIToolkitProfile> newProfile;
+ rv = GetCurrentProfile(mProfileSvc, mProfD, getter_AddRefs(newProfile));
+ if (NS_SUCCEEDED(rv)) {
+ newProfile->SetName(gResetOldProfileName);
+ mProfileName.Assign(gResetOldProfileName);
+ // Set the new profile as the default after we're done cleaning up the old profile,
+ // iff that profile was already the default
+ if (profileWasSelected) {
+ rv = mProfileSvc->SetDefaultProfile(newProfile);
+ if (NS_FAILED(rv)) NS_WARNING("Could not set current profile as the default");
+ }
+ } else {
+ NS_WARNING("Could not find current profile to set as default / change name.");
}
- // Need to write out the fact that the profile has been removed and potentially
- // that the selected/default profile changed.
+
+ // Need to write out the fact that the profile has been removed, the new profile
+ // renamed, and potentially that the selected/default profile changed.
mProfileSvc->Flush();
}
}