cleanup: initialize profiles when state is initiaized (#153002)

clean up:
- initialize profiles when state is initiaized
This commit is contained in:
Sandeep Somavarapu 2022-06-23 19:21:28 +02:00 committed by GitHub
parent 080c9a2611
commit 28e9322f72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 8 deletions

View file

@ -249,7 +249,7 @@ class CodeMain {
].map(path => path ? FSPromises.mkdir(path, { recursive: true }) : undefined)),
// State service
stateMainService.init().then(() => userDataProfilesMainService.init()),
stateMainService.init(),
// Configuration service
configurationService.initialize()

View file

@ -160,7 +160,7 @@ class CliMain extends Disposable {
// Initialize
await Promise.all([
stateService.init().then(() => userDataProfilesService.init()),
stateService.init(),
configurationService.initialize()
]);

View file

@ -11,6 +11,8 @@ export interface IStateService {
readonly _serviceBrand: undefined;
readonly whenInitialized: Promise<void>;
getItem<T>(key: string, defaultValue: T): T;
getItem<T>(key: string, defaultValue?: T): T | undefined;

View file

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ThrottledDelayer } from 'vs/base/common/async';
import { Barrier, ThrottledDelayer } from 'vs/base/common/async';
import { VSBuffer } from 'vs/base/common/buffer';
import { isUndefined, isUndefinedOrNull } from 'vs/base/common/types';
import { URI } from 'vs/base/common/uri';
@ -150,16 +150,22 @@ export class StateService implements IStateService {
protected readonly fileStorage: FileStorage;
private readonly initBarrier: Barrier;
readonly whenInitialized: Promise<void>;
constructor(
@IEnvironmentService environmentService: IEnvironmentService,
@ILogService logService: ILogService,
@IFileService fileService: IFileService
) {
this.fileStorage = new FileStorage(environmentService.stateResource, logService, fileService);
this.initBarrier = new Barrier();
this.whenInitialized = this.initBarrier.wait().then(() => undefined);
}
async init(): Promise<void> {
return this.fileStorage.init();
await this.fileStorage.init();
this.initBarrier.open();
}
getItem<T>(key: string, defaultValue: T): T;

View file

@ -44,10 +44,7 @@ export class UserDataProfilesService extends BaseUserDataProfilesService impleme
@ILogService logService: ILogService,
) {
super(environmentService, fileService, logService);
}
init(): void {
this._profilesObject = undefined;
stateService.whenInitialized.then(() => this._profilesObject = undefined);
}
protected _profilesObject: UserDataProfilesObject | undefined;