Skip to content

Change storageUri to globalStorageUri for log and session files #4093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/features/ExternalApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
8 changes: 1 addition & 7 deletions src/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<IPower
});

// Setup the logger.
logger = new Logger(context.storageUri);
logger = new Logger(context.globalStorageUri);
logger.MinimumLogLevel = LogLevel[extensionSettings.developer.editorServicesLogLevel];

sessionManager =
Expand Down
6 changes: 1 addition & 5 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,7 @@ export class SessionManager implements Middleware {
private telemetryReporter: TelemetryReporter) {

// Create a folder for the session files.
if (extensionContext.storageUri !== undefined) {
this.sessionsFolder = vscode.Uri.joinPath(extensionContext.storageUri, "sessions");
} else {
this.sessionsFolder = vscode.Uri.file(path.resolve(__dirname, "../sessions"));
}
this.sessionsFolder = vscode.Uri.joinPath(extensionContext.globalStorageUri, "sessions");
vscode.workspace.fs.createDirectory(this.sessionsFolder);

this.platformDetails = getPlatformDetails();
Expand Down
8 changes: 4 additions & 4 deletions test/core/paths.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { IPowerShellExtensionClient } from "../../src/features/ExternalApi";
import utils = require("../utils");

describe("Path assumptions", function () {
let storageUri: vscode.Uri;
let globalStorageUri: vscode.Uri;
before(async () => {
const extension: IPowerShellExtensionClient = await utils.ensureEditorServicesIsConnected();
storageUri = extension.getStorageUri();
globalStorageUri = extension.getStorageUri();
});

// TODO: This is skipped because it interferes with other tests. Either
Expand All @@ -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));
});
});