Skip to content

Commit 3aec497

Browse files
committed
Fill out storage function comments
And standardize url capitalization in its functions.
1 parent 93e5f1a commit 3aec497

File tree

4 files changed

+29
-15
lines changed

4 files changed

+29
-15
lines changed

src/commands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export class Commands {
154154
this.restClient.setSessionToken(token)
155155

156156
// Store these to be used in later sessions.
157-
await this.storage.setURL(url)
157+
await this.storage.setUrl(url)
158158
await this.storage.setSessionToken(token)
159159

160160
// Store on disk to be used by the cli.
@@ -212,7 +212,7 @@ export class Commands {
212212
this.restClient.setSessionToken("")
213213

214214
// Clear from memory.
215-
await this.storage.setURL(undefined)
215+
await this.storage.setUrl(undefined)
216216
await this.storage.setSessionToken(undefined)
217217

218218
// Clear from disk.

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
110110
const url = await commands.maybeAskUrl(params.get("url"), storage.getUrl())
111111
if (url) {
112112
restClient.setHost(url)
113-
await storage.setURL(url)
113+
await storage.setUrl(url)
114114
} else {
115115
throw new Error("url must be provided or specified as a query parameter")
116116
}

src/remote.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ export class Remote {
634634
ProxyCommand: `${escape(binaryPath)}${headerArg} vscodessh --network-info-dir ${escape(
635635
this.storage.getNetworkInfoPath(),
636636
)}${logArg} --session-token-file ${escape(this.storage.getSessionTokenPath(label))} --url-file ${escape(
637-
this.storage.getURLPath(label),
637+
this.storage.getUrlPath(label),
638638
)} %h`,
639639
ConnectTimeout: "0",
640640
StrictHostKeyChecking: "no",

src/storage.ts

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class Storage {
2828
* If the URL is falsey, then remove it as the last used URL and do not touch
2929
* the history.
3030
*/
31-
public async setURL(url?: string): Promise<void> {
31+
public async setUrl(url?: string): Promise<void> {
3232
await this.memento.update("url", url)
3333
if (url) {
3434
const history = this.withUrlHistory(url)
@@ -85,9 +85,11 @@ export class Storage {
8585
}
8686
}
8787

88-
// getRemoteSSHLogPath returns the log path for the "Remote - SSH" output panel.
89-
// There is no VS Code API to get the contents of an output panel. We use this
90-
// to get the active port so we can display network information.
88+
/**
89+
* Returns the log path for the "Remote - SSH" output panel. There is no VS
90+
* Code API to get the contents of an output panel. We use this to get the
91+
* active port so we can display network information.
92+
*/
9193
public async getRemoteSSHLogPath(): Promise<string | undefined> {
9294
const upperDir = path.dirname(this.logUri.fsPath)
9395
// Node returns these directories sorted already!
@@ -368,18 +370,30 @@ export class Storage {
368370
: path.join(this.globalStorageUri.fsPath, "bin")
369371
}
370372

371-
// getNetworkInfoPath returns the path where network information
372-
// for SSH hosts is stored.
373+
/**
374+
* Return the path where network information for SSH hosts are stored.
375+
*
376+
* The CLI will write files here named after the process PID.
377+
*/
373378
public getNetworkInfoPath(): string {
374379
return path.join(this.globalStorageUri.fsPath, "net")
375380
}
376381

377-
// getLogPath returns the path where log data from the Coder
378-
// agent is stored.
382+
/**
383+
*
384+
* Return the path where log data from the connection is stored.
385+
*
386+
* The CLI will write files here named after the process PID.
387+
*/
379388
public getLogPath(): string {
380389
return path.join(this.globalStorageUri.fsPath, "log")
381390
}
382391

392+
/**
393+
* Get the path to the user's settings.json file.
394+
*
395+
* Going through VSCode's API should be preferred when modifying settings.
396+
*/
383397
public getUserSettingsPath(): string {
384398
return path.join(this.globalStorageUri.fsPath, "..", "..", "..", "User", "settings.json")
385399
}
@@ -406,7 +420,7 @@ export class Storage {
406420
*
407421
* The caller must ensure this directory exists before use.
408422
*/
409-
public getURLPath(label: string): string {
423+
public getUrlPath(label: string): string {
410424
return label
411425
? path.join(this.globalStorageUri.fsPath, label, "url")
412426
: path.join(this.globalStorageUri.fsPath, "url")
@@ -434,7 +448,7 @@ export class Storage {
434448
* If the label is empty, read the old deployment-unaware config instead.
435449
*/
436450
private async updateUrlForCli(label: string, url: string | undefined): Promise<void> {
437-
const urlPath = this.getURLPath(label)
451+
const urlPath = this.getUrlPath(label)
438452
if (url) {
439453
await fs.mkdir(path.dirname(urlPath), { recursive: true })
440454
await fs.writeFile(urlPath, url)
@@ -467,7 +481,7 @@ export class Storage {
467481
* If the label is empty, read the old deployment-unaware config.
468482
*/
469483
public async readCliConfig(label: string): Promise<{ url: string; token: string }> {
470-
const urlPath = this.getURLPath(label)
484+
const urlPath = this.getUrlPath(label)
471485
const tokenPath = this.getSessionTokenPath(label)
472486
const [url, token] = await Promise.allSettled([fs.readFile(urlPath, "utf8"), fs.readFile(tokenPath, "utf8")])
473487
return {

0 commit comments

Comments
 (0)