Make state service async (#122977)

* state service - make it electron-main only

* state service - make writes async

* some cleanup

* more cleanup and removal of sync fs
This commit is contained in:
Benjamin Pasero
2021-05-05 09:30:12 +02:00
committed by GitHub
parent 9ddbdf449b
commit 8b2f0222be
16 changed files with 236 additions and 154 deletions

View File

@@ -23,7 +23,7 @@ import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiati
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { ILoggerService, ILogService } from 'vs/platform/log/common/log';
import { IStateService } from 'vs/platform/state/node/state';
import { IStateMainService } from 'vs/platform/state/electron-main/state';
import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IOpenURLOptions, IURLService } from 'vs/platform/url/common/url';
@@ -107,7 +107,7 @@ export class CodeApplication extends Disposable {
@IEnvironmentMainService private readonly environmentMainService: IEnvironmentMainService,
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IStateService private readonly stateService: IStateService,
@IStateMainService private readonly stateMainService: IStateMainService,
@IFileService private readonly fileService: IFileService,
@IProductService private readonly productService: IProductService
) {
@@ -458,11 +458,11 @@ export class CodeApplication extends Disposable {
// We cache the machineId for faster lookups on startup
// and resolve it only once initially if not cached or we need to replace the macOS iBridge device
let machineId = this.stateService.getItem<string>(machineIdKey);
let machineId = this.stateMainService.getItem<string>(machineIdKey);
if (!machineId || (isMacintosh && machineId === '6c9d2bc8f91b89624add29c0abeae7fb42bf539fa1cdb2e3e57cd668fa9bcead')) {
machineId = await getMachineId();
this.stateService.setItem(machineIdKey, machineId);
this.stateMainService.setItem(machineIdKey, machineId);
}
return machineId;