Skip to content

Commit 09f3865

Browse files
committed
fixup
1 parent d2d99c5 commit 09f3865

File tree

3 files changed

+29
-34
lines changed

3 files changed

+29
-34
lines changed

packages/core/src/shared/fs/fs.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,34 @@ export class FileSystem {
600600
return this.#homeDir
601601
}
602602

603+
/**
604+
* Gets the application cache folder for the current platform
605+
*
606+
* Follows the cache_dir convention outlined in https://crates.io/crates/dirs
607+
*/
608+
getCacheDir(): string {
609+
switch (process.platform) {
610+
case 'darwin': {
611+
return _path.join(this.getUserHomeDir(), 'Library/Caches')
612+
}
613+
case 'win32': {
614+
const localAppData = process.env.LOCALAPPDATA
615+
if (!localAppData) {
616+
throw new ToolkitError('LOCALAPPDATA environment variable not set', {
617+
code: 'LocalAppDataNotFound',
618+
})
619+
}
620+
return localAppData
621+
}
622+
case 'linux': {
623+
return _path.join(this.getUserHomeDir(), '.cache')
624+
}
625+
default: {
626+
throw new Error(`Unsupported platform: ${process.platform}. Expected 'darwin', 'win32', or 'linux'.`)
627+
}
628+
}
629+
}
630+
603631
/**
604632
* Gets the (cached) username for this session, or "webuser" in web-mode, or "unknown-user" if
605633
* a username could not be resolved.

packages/core/src/shared/languageServer/lspResolver.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import * as path from 'path'
1010
import { FileType } from 'vscode'
1111
import AdmZip from 'adm-zip'
1212
import { TargetContent, logger, LspResult, LspVersion, Manifest } from './types'
13-
import { getApplicationCacheFolder } from '../vscode/env'
1413
import { createHash } from '../crypto'
1514
import request from '../request'
1615

@@ -341,7 +340,7 @@ export class LanguageServerResolver {
341340
}
342341

343342
private defaultDownloadFolder() {
344-
const applicationCacheFolder = getApplicationCacheFolder()
343+
const applicationCacheFolder = fs.getCacheDir()
345344
return path.join(applicationCacheFolder, `aws/toolkits/language-servers/${this.lsName}`)
346345
}
347346

packages/core/src/shared/vscode/env.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ import { onceChanged } from '../utilities/functionUtils'
1212
import { ChildProcess } from '../utilities/processUtils'
1313
import globals, { isWeb } from '../extensionGlobals'
1414
import * as devConfig from '../../dev/config'
15-
import path from 'path'
16-
import { fs } from '../fs/fs'
17-
import { ToolkitError } from '../errors'
1815

1916
/**
2017
* Returns true if the current build is running on CI (build server).
@@ -273,32 +270,3 @@ export async function getMachineId(): Promise<string> {
273270
// TODO: check exit code.
274271
return (await proc.run()).stdout.trim() ?? 'unknown-host'
275272
}
276-
277-
/**
278-
* Gets the application cache folder for the current platform
279-
*
280-
* Follows the cache_dir convention outlined in https://crates.io/crates/dirs
281-
*/
282-
export function getApplicationCacheFolder() {
283-
const homeDir = fs.getUserHomeDir()
284-
switch (process.platform) {
285-
case 'darwin': {
286-
return path.join(homeDir, 'Library/Caches')
287-
}
288-
case 'win32': {
289-
const localAppData = process.env.LOCALAPPDATA
290-
if (!localAppData) {
291-
throw new ToolkitError('LOCALAPPDATA environment variable not set', {
292-
code: 'LocalAppDataNotFound',
293-
})
294-
}
295-
return localAppData
296-
}
297-
case 'linux': {
298-
return path.join(homeDir, '.cache')
299-
}
300-
default: {
301-
throw new Error(`Unsupported platform: ${process.platform}. Expected 'darwin', 'win32', or 'linux'.`)
302-
}
303-
}
304-
}

0 commit comments

Comments
 (0)