diff options
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/config.ts | 23 | ||||
-rw-r--r-- | editors/code/src/installation/download_file.ts | 16 |
2 files changed, 31 insertions, 8 deletions
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index d5f3da2ed..418845436 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts | |||
@@ -64,9 +64,24 @@ export class Config { | |||
64 | * `platform` on GitHub releases. (It is also stored under the same name when | 64 | * `platform` on GitHub releases. (It is also stored under the same name when |
65 | * downloaded by the extension). | 65 | * downloaded by the extension). |
66 | */ | 66 | */ |
67 | private static prebuiltLangServerFileName(platform: NodeJS.Platform): null | string { | 67 | private static prebuiltLangServerFileName( |
68 | platform: NodeJS.Platform, | ||
69 | arch: string | ||
70 | ): null | string { | ||
71 | // See possible `arch` values here: | ||
72 | // https://nodejs.org/api/process.html#process_process_arch | ||
73 | |||
68 | switch (platform) { | 74 | switch (platform) { |
69 | case "linux": return "ra_lsp_server-linux"; | 75 | |
76 | case "linux": { | ||
77 | switch (arch) { | ||
78 | case "arm": | ||
79 | case "arm64": return null; | ||
80 | |||
81 | default: return "ra_lsp_server-linux"; | ||
82 | } | ||
83 | } | ||
84 | |||
70 | case "darwin": return "ra_lsp_server-mac"; | 85 | case "darwin": return "ra_lsp_server-mac"; |
71 | case "win32": return "ra_lsp_server-windows.exe"; | 86 | case "win32": return "ra_lsp_server-windows.exe"; |
72 | 87 | ||
@@ -95,7 +110,9 @@ export class Config { | |||
95 | }; | 110 | }; |
96 | } | 111 | } |
97 | 112 | ||
98 | const prebuiltBinaryName = Config.prebuiltLangServerFileName(process.platform); | 113 | const prebuiltBinaryName = Config.prebuiltLangServerFileName( |
114 | process.platform, process.arch | ||
115 | ); | ||
99 | 116 | ||
100 | if (!prebuiltBinaryName) return null; | 117 | if (!prebuiltBinaryName) return null; |
101 | 118 | ||
diff --git a/editors/code/src/installation/download_file.ts b/editors/code/src/installation/download_file.ts index b51602ef9..8a0766c66 100644 --- a/editors/code/src/installation/download_file.ts +++ b/editors/code/src/installation/download_file.ts | |||
@@ -13,22 +13,28 @@ export async function downloadFile( | |||
13 | destFilePath: fs.PathLike, | 13 | destFilePath: fs.PathLike, |
14 | onProgress: (readBytes: number, totalBytes: number) => void | 14 | onProgress: (readBytes: number, totalBytes: number) => void |
15 | ): Promise<void> { | 15 | ): Promise<void> { |
16 | const response = await fetch(url); | 16 | const res = await fetch(url); |
17 | 17 | ||
18 | const totalBytes = Number(response.headers.get('content-length')); | 18 | if (!res.ok) { |
19 | console.log("Error", res.status, "while downloading file from", url); | ||
20 | console.dir({ body: await res.text(), headers: res.headers }, { depth: 3 }); | ||
21 | |||
22 | throw new Error(`Got response ${res.status} when trying to download a file`); | ||
23 | } | ||
24 | |||
25 | const totalBytes = Number(res.headers.get('content-length')); | ||
19 | assert(!Number.isNaN(totalBytes), "Sanity check of content-length protocol"); | 26 | assert(!Number.isNaN(totalBytes), "Sanity check of content-length protocol"); |
20 | 27 | ||
21 | let readBytes = 0; | 28 | let readBytes = 0; |
22 | 29 | ||
23 | console.log("Downloading file of", totalBytes, "bytes size from", url, "to", destFilePath); | 30 | console.log("Downloading file of", totalBytes, "bytes size from", url, "to", destFilePath); |
24 | 31 | ||
25 | return new Promise<void>((resolve, reject) => response.body | 32 | return new Promise<void>((resolve, reject) => res.body |
26 | .on("data", (chunk: Buffer) => { | 33 | .on("data", (chunk: Buffer) => { |
27 | readBytes += chunk.length; | 34 | readBytes += chunk.length; |
28 | onProgress(readBytes, totalBytes); | 35 | onProgress(readBytes, totalBytes); |
29 | }) | 36 | }) |
30 | .on("end", resolve) | ||
31 | .on("error", reject) | 37 | .on("error", reject) |
32 | .pipe(fs.createWriteStream(destFilePath)) | 38 | .pipe(fs.createWriteStream(destFilePath).on("close", resolve)) |
33 | ); | 39 | ); |
34 | } | 40 | } |