From 8e03f48032802ec4d4462d681a9b92d8551589ac Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Tue, 26 Jul 2022 08:30:56 -0700 Subject: [PATCH] Change `storageUri` to `globalStorageUri` for log and session files Instead of being workspace specific, as the extension itself is not. Also no chance of it being undefined. --- src/features/ExternalApi.ts | 2 +- src/logging.ts | 8 +------- src/main.ts | 2 +- src/session.ts | 6 +----- test/core/paths.test.ts | 8 ++++---- 5 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/features/ExternalApi.ts b/src/features/ExternalApi.ts index 9ae950bace..cd5d32bfb4 100644 --- a/src/features/ExternalApi.ts +++ b/src/features/ExternalApi.ts @@ -168,7 +168,7 @@ export class ExternalApiFeature extends LanguageClientConsumer implements IPower } public getStorageUri(): vscode.Uri { - return this.extensionContext.storageUri; + return this.extensionContext.globalStorageUri; } public dispose() { diff --git a/src/logging.ts b/src/logging.ts index d98a7e7185..daaa894792 100644 --- a/src/logging.ts +++ b/src/logging.ts @@ -39,13 +39,7 @@ export class Logger implements ILogger { constructor(logBasePath: vscode.Uri) { this.logChannel = vscode.window.createOutputChannel("PowerShell Extension Logs"); - - if (logBasePath === undefined) { - // No workspace, we have to use another folder. - this.logBasePath = vscode.Uri.file(path.resolve(__dirname, "../logs")); - } else { - this.logBasePath = vscode.Uri.joinPath(logBasePath, "logs"); - } + this.logBasePath = vscode.Uri.joinPath(logBasePath, "logs"); this.commands = [ vscode.commands.registerCommand( diff --git a/src/main.ts b/src/main.ts index 8a48463662..bb373655b6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -125,7 +125,7 @@ export async function activate(context: vscode.ExtensionContext): Promise { const extension: IPowerShellExtensionClient = await utils.ensureEditorServicesIsConnected(); - storageUri = extension.getStorageUri(); + globalStorageUri = extension.getStorageUri(); }); // TODO: This is skipped because it interferes with other tests. Either @@ -23,10 +23,10 @@ describe("Path assumptions", function () { }); it("Creates the session folder at the correct path", function () { - assert(fs.existsSync(vscode.Uri.joinPath(storageUri, "sessions").fsPath)); + assert(fs.existsSync(vscode.Uri.joinPath(globalStorageUri, "sessions").fsPath)); }); it("Creates the log folder at the correct path", function () { - assert(fs.existsSync(vscode.Uri.joinPath(storageUri, "logs").fsPath)); + assert(fs.existsSync(vscode.Uri.joinPath(globalStorageUri, "logs").fsPath)); }); });