#23251 Expose global storage path in proposed API

This commit is contained in:
Sandeep Somavarapu
2018-11-28 16:33:59 +01:00
parent c083f2113a
commit 37037eac8a
5 changed files with 25 additions and 3 deletions

View File

@@ -50,6 +50,7 @@ export interface IEnvironment {
appSettingsHome: URI;
extensionDevelopmentLocationURI: URI;
extensionTestsPath: string;
globalStorageHome: string;
}
export interface IWorkspaceData {

View File

@@ -23,6 +23,7 @@ export interface IExtensionContext {
globalState: IExtensionMemento;
extensionPath: string;
storagePath: string;
globalStoragePath: string;
asAbsolutePath(relativePath: string): string;
readonly logPath: string;
}

View File

@@ -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)
});