From c29a502e2549aba7e47a6f40581e5ccf74b5f481 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 8 Mar 2020 00:01:48 +0200 Subject: vscode: care about alwaysDownloadServer option before asking Also renamed BinarySource to ArtifactSource in anticipation of nightlies installation that requires downloading not a binary itself but .vsix package, thus generalized to `artifact` term --- editors/code/src/installation/interfaces.ts | 15 ++++++++++----- editors/code/src/installation/server.ts | 28 +++++++++++++++------------- 2 files changed, 25 insertions(+), 18 deletions(-) (limited to 'editors/code/src/installation') diff --git a/editors/code/src/installation/interfaces.ts b/editors/code/src/installation/interfaces.ts index e40839e4b..50b635921 100644 --- a/editors/code/src/installation/interfaces.ts +++ b/editors/code/src/installation/interfaces.ts @@ -14,14 +14,14 @@ export interface ArtifactReleaseInfo { } /** - * Represents the source of a binary artifact which is either specified by the user + * Represents the source of a an artifact which is either specified by the user * explicitly, or bundled by this extension from GitHub releases. */ -export type BinarySource = BinarySource.ExplicitPath | BinarySource.GithubRelease; +export type ArtifactSource = ArtifactSource.ExplicitPath | ArtifactSource.GithubRelease; -export namespace BinarySource { +export namespace ArtifactSource { /** - * Type tag for `BinarySource` discriminated union. + * Type tag for `ArtifactSource` discriminated union. */ export const enum Type { ExplicitPath, GithubRelease } @@ -56,13 +56,18 @@ export namespace BinarySource { /** * Tag of github release that denotes a version required by this extension. */ - version: string; + tag: string; /** * Object that provides `get()/update()` operations to store metadata * about the actual binary, e.g. its actual version. */ storage: vscode.Memento; + + /** + * Ask for the user permission before downloading the artifact. + */ + askBeforeDownload: boolean; } } diff --git a/editors/code/src/installation/server.ts b/editors/code/src/installation/server.ts index 6a6cf4f8c..ef1c45ff6 100644 --- a/editors/code/src/installation/server.ts +++ b/editors/code/src/installation/server.ts @@ -3,12 +3,12 @@ import * as path from "path"; import { promises as dns } from "dns"; import { spawnSync } from "child_process"; -import { BinarySource } from "./interfaces"; +import { ArtifactSource } from "./interfaces"; import { fetchArtifactReleaseInfo } from "./fetch_artifact_release_info"; import { downloadArtifact } from "./download_artifact"; import { log, assert } from "../util"; -export async function ensureServerBinary(source: null | BinarySource): Promise { +export async function ensureServerBinary(source: null | ArtifactSource): Promise { if (!source) { vscode.window.showErrorMessage( "Unfortunately we don't ship binaries for your platform yet. " + @@ -22,7 +22,7 @@ export async function ensureServerBinary(source: null | BinarySource): Promise { +async function downloadServer(source: ArtifactSource.GithubRelease): Promise { try { - const releaseInfo = await fetchArtifactReleaseInfo(source.repo, source.file, source.version); + const releaseInfo = await fetchArtifactReleaseInfo(source.repo, source.file, source.tag); await downloadArtifact(releaseInfo, source.file, source.dir, "language server"); await setServerVersion(source.storage, releaseInfo.releaseName); -- cgit v1.2.3