@@ -3,12 +3,12 @@ import * as path from "path";
33import { promises as dns } from "dns" ;
44import { spawnSync } from "child_process" ;
55
6- import { BinarySource } from "./interfaces" ;
6+ import { ArtifactSource } from "./interfaces" ;
77import { fetchArtifactReleaseInfo } from "./fetch_artifact_release_info" ;
88import { downloadArtifact } from "./download_artifact" ;
99import { log , assert } from "../util" ;
1010
11- export async function ensureServerBinary ( source : null | BinarySource ) : Promise < null | string > {
11+ export async function ensureServerBinary ( source : null | ArtifactSource ) : Promise < null | string > {
1212 if ( ! source ) {
1313 vscode . window . showErrorMessage (
1414 "Unfortunately we don't ship binaries for your platform yet. " +
@@ -22,7 +22,7 @@ export async function ensureServerBinary(source: null | BinarySource): Promise<n
2222 }
2323
2424 switch ( source . type ) {
25- case BinarySource . Type . ExplicitPath : {
25+ case ArtifactSource . Type . ExplicitPath : {
2626 if ( isBinaryAvailable ( source . path ) ) {
2727 return source . path ;
2828 }
@@ -34,24 +34,26 @@ export async function ensureServerBinary(source: null | BinarySource): Promise<n
3434 ) ;
3535 return null ;
3636 }
37- case BinarySource . Type . GithubRelease : {
37+ case ArtifactSource . Type . GithubRelease : {
3838 const prebuiltBinaryPath = path . join ( source . dir , source . file ) ;
3939
4040 const installedVersion : null | string = getServerVersion ( source . storage ) ;
41- const requiredVersion : string = source . version ;
41+ const requiredVersion : string = source . tag ;
4242
4343 log . debug ( "Installed version:" , installedVersion , "required:" , requiredVersion ) ;
4444
4545 if ( isBinaryAvailable ( prebuiltBinaryPath ) && installedVersion === requiredVersion ) {
4646 return prebuiltBinaryPath ;
4747 }
4848
49- const userResponse = await vscode . window . showInformationMessage (
50- `Language server version ${ source . version } for rust-analyzer is not installed. ` +
51- "Do you want to download it now?" ,
52- "Download now" , "Cancel"
53- ) ;
54- if ( userResponse !== "Download now" ) return null ;
49+ if ( source . askBeforeDownload ) {
50+ const userResponse = await vscode . window . showInformationMessage (
51+ `Language server version ${ source . tag } for rust-analyzer is not installed. ` +
52+ "Do you want to download it now?" ,
53+ "Download now" , "Cancel"
54+ ) ;
55+ if ( userResponse !== "Download now" ) return null ;
56+ }
5557
5658 if ( ! await downloadServer ( source ) ) return null ;
5759
@@ -60,9 +62,9 @@ export async function ensureServerBinary(source: null | BinarySource): Promise<n
6062 }
6163}
6264
63- async function downloadServer ( source : BinarySource . GithubRelease ) : Promise < boolean > {
65+ async function downloadServer ( source : ArtifactSource . GithubRelease ) : Promise < boolean > {
6466 try {
65- const releaseInfo = await fetchArtifactReleaseInfo ( source . repo , source . file , source . version ) ;
67+ const releaseInfo = await fetchArtifactReleaseInfo ( source . repo , source . file , source . tag ) ;
6668
6769 await downloadArtifact ( releaseInfo , source . file , source . dir , "language server" ) ;
6870 await setServerVersion ( source . storage , releaseInfo . releaseName ) ;
0 commit comments