Bug 1915216: Add a method to asynchronously write the important data about the current profile to the INI file on disk. r=glandium,jhirsch,pehrsons,backup-reviewers,mconley
This adds an asynchronous method to lock the startup files using the same lock that we use during normal startup. The profile service then uses this lock to gate access to the profiles.ini files adding a method to async flush the entire database or in the case that the on-disk database has changed a way to mergwe in some properties about the current profile into the on-disk version. Differential Revision: https://phabricator.services.mozilla.com/D222662
This commit is contained in:
@@ -32,6 +32,14 @@ XPCOMUtils.defineLazyServiceGetter(
|
||||
|
||||
const PROFILES_CRYPTO_SALT_LENGTH_BYTES = 16;
|
||||
|
||||
async function attemptFlush() {
|
||||
try {
|
||||
await lazy.ProfileService.asyncFlush();
|
||||
} catch (e) {
|
||||
await lazy.ProfileService.asyncFlushCurrentProfile();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The service that manages selectable profiles
|
||||
*/
|
||||
@@ -100,7 +108,7 @@ class SelectableProfileServiceClass {
|
||||
.replace("{", "")
|
||||
.split("-")[0];
|
||||
this.#groupToolkitProfile.storeID = storageID;
|
||||
lazy.ProfileService.flush();
|
||||
await attemptFlush();
|
||||
}
|
||||
|
||||
async getProfilesStorePath() {
|
||||
@@ -317,7 +325,7 @@ class SelectableProfileServiceClass {
|
||||
}
|
||||
|
||||
this.#groupToolkitProfile.storeID = null;
|
||||
lazy.ProfileService.flush();
|
||||
await attemptFlush();
|
||||
await this.vacuumAndCloseGroupDB();
|
||||
}
|
||||
|
||||
@@ -386,7 +394,7 @@ class SelectableProfileServiceClass {
|
||||
return;
|
||||
}
|
||||
this.#groupToolkitProfile.rootDir = await this.currentProfile.rootDir;
|
||||
lazy.ProfileService.flush();
|
||||
await attemptFlush();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -395,13 +403,13 @@ class SelectableProfileServiceClass {
|
||||
*
|
||||
* @param {boolean} shouldShow Whether or not we should show the profile selector
|
||||
*/
|
||||
showProfileSelectorWindow(shouldShow) {
|
||||
async showProfileSelectorWindow(shouldShow) {
|
||||
if (shouldShow === this.groupToolkitProfile.showProfileSelector) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.groupToolkitProfile.showProfileSelector = shouldShow;
|
||||
lazy.ProfileService.flush();
|
||||
await attemptFlush();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user