提交 37037eac 编写于 作者: S Sandeep Somavarapu

#23251 Expose global storage path in proposed API

上级 c083f211
......@@ -1147,4 +1147,18 @@ declare module 'vscode' {
}
//#endregion
//#region Extension Context
export interface ExtensionContext {
/**
* An absolute file path in which the extension can store gloabal state.
* The directory might not exist on disk and creation is
* up to the extension. However, the parent directory is guaranteed to be existent.
*
* Use [`globalState`](#ExtensionContext.globalState) to store key value data.
*/
globalStoragePath: string;
}
//#endregion
}
......@@ -50,6 +50,7 @@ export interface IEnvironment {
appSettingsHome: URI;
extensionDevelopmentLocationURI: URI;
extensionTestsPath: string;
globalStorageHome: string;
}
export interface IWorkspaceData {
......
......@@ -23,6 +23,7 @@ export interface IExtensionContext {
globalState: IExtensionMemento;
extensionPath: string;
storagePath: string;
globalStoragePath: string;
asAbsolutePath(relativePath: string): string;
readonly logPath: string;
}
......
......@@ -91,13 +91,17 @@ class ExtensionStoragePath {
return this._ready;
}
value(extension: IExtensionDescription): string {
workspaceValue(extension: IExtensionDescription): string {
if (this._value) {
return join(this._value, extension.id);
}
return undefined;
}
globalValue(extension: IExtensionDescription): string {
return join(this._environment.globalStorageHome, extension.id);
}
private async _getOrCreateWorkspaceStoragePath(): Promise<string> {
if (!this._workspace) {
return Promise.resolve(undefined);
......@@ -383,7 +387,8 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
workspaceState,
subscriptions: [],
get extensionPath() { return extensionDescription.extensionLocation.fsPath; },
storagePath: this._storagePath.value(extensionDescription),
storagePath: this._storagePath.workspaceValue(extensionDescription),
globalStoragePath: this._storagePath.globalValue(extensionDescription),
asAbsolutePath: (relativePath: string) => { return join(extensionDescription.extensionLocation.fsPath, relativePath); },
logPath: that._extHostLogService.getLogDirectory(extensionDescription.id)
});
......
......@@ -424,7 +424,8 @@ export class ExtensionHostProcessWorker implements IExtensionHostStarter {
appRoot: this._environmentService.appRoot ? URI.file(this._environmentService.appRoot) : void 0,
appSettingsHome: this._environmentService.appSettingsHome ? URI.file(this._environmentService.appSettingsHome) : void 0,
extensionDevelopmentLocationURI: this._environmentService.extensionDevelopmentLocationURI,
extensionTestsPath: this._environmentService.extensionTestsPath
extensionTestsPath: this._environmentService.extensionTestsPath,
globalStorageHome: this._environmentService.globalStorageHome
},
workspace: this._contextService.getWorkbenchState() === WorkbenchState.EMPTY ? null : {
configuration: workspace.configuration,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册