提交 9eceaa4c 编写于 作者: B Benjamin Pasero

storage - less waterfall startup

上级 4b2fac2b
......@@ -112,15 +112,13 @@ function openWorkbench(configuration: IWindowConfiguration): Promise<void> {
// Resolve a workspace payload that we can get the workspace ID from
return createWorkspaceInitializationPayload(configuration, environmentService).then(payload => {
// Prepare the workspace storage folder
return prepareWorkspaceStorageFolder(payload, environmentService).then(workspaceStoragePath => {
return Promise.all([
// Create and initialize workspace/configuration service
createWorkspaceService(payload, environmentService, logService),
// Create and initialize storage service
createStorageService(workspaceStoragePath, payload, environmentService, logService)
createStorageService(payload, environmentService, logService)
]).then(services => {
const workspaceService = services[0];
const storageService = new DelegatingStorageService(services[1], createStorageLegacyService(workspaceService, environmentService), logService, workspaceService);
......@@ -139,7 +137,7 @@ function openWorkbench(configuration: IWindowConfiguration): Promise<void> {
// Store meta file in workspace storage after workbench is running
shell.onRunning(() => {
ensureWorkspaceStorageFolderMeta(workspaceStoragePath, workspaceService);
ensureWorkspaceStorageFolderMeta(payload, workspaceService, environmentService);
});
// Gracefully Shutdown Storage
......@@ -161,7 +159,6 @@ function openWorkbench(configuration: IWindowConfiguration): Promise<void> {
});
});
});
});
}
function createWorkspaceInitializationPayload(configuration: IWindowConfiguration, environmentService: EnvironmentService): Promise<IWorkspaceInitializationPayload> {
......@@ -234,8 +231,12 @@ function resolveSingleFolderWorkspaceInitializationPayload(folderUri: ISingleFol
}, error => onUnexpectedError(error));
}
function getWorkspaceStoragePath(payload: IWorkspaceInitializationPayload, environmentService: IEnvironmentService): string {
return join(environmentService.workspaceStorageHome, payload.id); // workspace home + workspace id;
}
function prepareWorkspaceStorageFolder(payload: IWorkspaceInitializationPayload, environmentService: IEnvironmentService): Thenable<string> {
const workspaceStoragePath = join(environmentService.workspaceStorageHome, payload.id); // workspace home + workspace id
const workspaceStoragePath = getWorkspaceStoragePath(payload, environmentService);
return exists(workspaceStoragePath).then(exists => {
if (exists) {
......@@ -246,13 +247,13 @@ function prepareWorkspaceStorageFolder(payload: IWorkspaceInitializationPayload,
});
}
function ensureWorkspaceStorageFolderMeta(workspaceStoragePath: string, workspaceService: IWorkspaceContextService): void {
function ensureWorkspaceStorageFolderMeta(payload: IWorkspaceInitializationPayload, workspaceService: IWorkspaceContextService, environmentService: IEnvironmentService): void {
const state = workspaceService.getWorkbenchState();
if (state === WorkbenchState.EMPTY) {
return; // no storage meta for empty workspaces
}
const workspaceStorageMetaPath = join(workspaceStoragePath, 'workspace.json');
const workspaceStorageMetaPath = join(getWorkspaceStoragePath(payload, environmentService), 'workspace.json');
exists(workspaceStorageMetaPath).then(exists => {
if (exists) {
......@@ -279,7 +280,10 @@ function createWorkspaceService(payload: IWorkspaceInitializationPayload, enviro
});
}
function createStorageService(workspaceStorageFolder: string, payload: IWorkspaceInitializationPayload, environmentService: IEnvironmentService, logService: ILogService): Thenable<StorageService> {
function createStorageService(payload: IWorkspaceInitializationPayload, environmentService: IEnvironmentService, logService: ILogService): Thenable<StorageService> {
// Prepare the workspace storage folder
return prepareWorkspaceStorageFolder(payload, environmentService).then(workspaceStorageFolder => {
// Return early if we are using in-memory storage
const useInMemoryStorage = !!environmentService.extensionTestsPath; /* never keep any state when running extension tests */
......@@ -427,6 +431,7 @@ function createStorageService(workspaceStorageFolder: string, payload: IWorkspac
});
});
});
});
}
function createStorageLegacyService(workspaceService: IWorkspaceContextService, environmentService: IEnvironmentService): IStorageLegacyService {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册