From 56e128a979082de4ea58b7739049405fbc43f394 Mon Sep 17 00:00:00 2001 From: wxb1ank Date: Tue, 15 Jun 2021 13:29:02 -0400 Subject: fix: clean-up #8951 --- editors/code/src/toolchain.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'editors/code/src/toolchain.ts') diff --git a/editors/code/src/toolchain.ts b/editors/code/src/toolchain.ts index 902d0ddda..355dd76fe 100644 --- a/editors/code/src/toolchain.ts +++ b/editors/code/src/toolchain.ts @@ -159,7 +159,7 @@ export const getPathForExecutable = memoize( // it is not mentioned in docs and cannot be infered by the type signature... const standardPath = vscode.Uri.joinPath(vscode.Uri.file(os.homedir()), ".cargo", "bin", executableName); - if (isFile(standardPath.path)) return standardPath.path; + if (isFileAtUri(standardPath)) return standardPath.fsPath; } catch (err) { log.error("Failed to read the fs info", err); } @@ -177,9 +177,17 @@ function lookupInPath(exec: string): boolean { : [candidate]; }); - return candidates.some(isFile); + return candidates.some(isFileAtPath); } -async function isFile(path: string): Promise { - return ((await vscode.workspace.fs.stat(vscode.Uri.file(path))).type & vscode.FileType.File) !== 0; +async function isFileAtPath(path: string): Promise { + return isFileAtUri(vscode.Uri.file(path)); +} + +async function isFileAtUri(uri: vscode.Uri): Promise { + try { + return ((await vscode.workspace.fs.stat(uri)).type & vscode.FileType.File) !== 0; + } catch { + return false; + } } -- cgit v1.2.3