mirror of
https://github.com/Microsoft/vscode
synced 2024-10-06 03:17:00 +00:00
cleanup: initialize profiles when state is initiaized (#153002)
clean up: - initialize profiles when state is initiaized
This commit is contained in:
parent
080c9a2611
commit
28e9322f72
|
@ -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()
|
||||
|
|
|
@ -160,7 +160,7 @@ class CliMain extends Disposable {
|
|||
|
||||
// Initialize
|
||||
await Promise.all([
|
||||
stateService.init().then(() => userDataProfilesService.init()),
|
||||
stateService.init(),
|
||||
configurationService.initialize()
|
||||
]);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue