From f3f19ed3ebf4bc6fc8c27b3dcdd3f55eca8c4a56 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Wed, 3 May 2023 10:49:42 -0500 Subject: [PATCH] fix: use user-data-dir for storage Fixes #79. --- src/commands.ts | 2 +- src/sshSupport.test.ts | 1 + src/sshSupport.ts | 6 ++++-- src/storage.ts | 15 +-------------- 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/commands.ts b/src/commands.ts index 9995e8bf..ad90873c 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -217,7 +217,7 @@ export class Commands { if (agents.length === 1) { folderPath = agents[0].expanded_directory workspaceAgent = agents[0].name - } else { + } else if (agents.length > 0) { const agentQuickPick = vscode.window.createQuickPick() agentQuickPick.title = `Select an agent` diff --git a/src/sshSupport.test.ts b/src/sshSupport.test.ts index f4db7831..4761f6ec 100644 --- a/src/sshSupport.test.ts +++ b/src/sshSupport.test.ts @@ -3,6 +3,7 @@ import { sshSupportsSetEnv, sshVersionSupportsSetEnv } from "./sshSupport" const supports = { "OpenSSH_8.9p1 Ubuntu-3ubuntu0.1, OpenSSL 3.0.2 15 Mar 2022": true, + "OpenSSH_9.0p1, LibreSSL 3.3.6": true, "OpenSSH_7.6p1 Ubuntu-4ubuntu0.7, OpenSSL 1.0.2n 7 Dec 2017": false, "OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017": false, } diff --git a/src/sshSupport.ts b/src/sshSupport.ts index 0100b04f..2121adad 100644 --- a/src/sshSupport.ts +++ b/src/sshSupport.ts @@ -24,10 +24,12 @@ export function sshVersionSupportsSetEnv(sshVersionString: string): boolean { return false } // 7.8 is the first version that supports SetEnv - if (Number.parseInt(parts[0], 10) < 7) { + const major = Number.parseInt(parts[0], 10) + const minor = Number.parseInt(parts[1], 10) + if (major < 7) { return false } - if (Number.parseInt(parts[1], 10) < 8) { + if (major === 7 && minor < 8) { return false } return true diff --git a/src/storage.ts b/src/storage.ts index 41c43fbe..4c3020e1 100644 --- a/src/storage.ts +++ b/src/storage.ts @@ -264,7 +264,7 @@ export class Storage { } public getUserSettingsPath(): string { - return path.join(this.appDataDir(), "Code", "User", "settings.json") + return path.join(this.globalStorageUri.fsPath, "..", "..", "..", "User", "settings.json") } public getSessionTokenPath(): string { @@ -292,19 +292,6 @@ export class Storage { }) } - private appDataDir(): string { - switch (process.platform) { - case "darwin": - return `${os.homedir()}/Library/Application Support` - case "linux": - return `${os.homedir()}/.config` - case "win32": - return process.env.APPDATA || "" - default: - return "/var/local" - } - } - private async updateURL(): Promise { const url = this.getURL() axios.defaults.baseURL = url