11import { field , logger } from "@coder/logger"
2- import zip from "adm-zip"
32import * as cp from "child_process"
43import * as fs from "fs-extra"
54import * as http from "http"
@@ -213,11 +212,7 @@ export class UpdateHttpProvider extends HttpProvider {
213212 const response = await this . requestResponse ( url )
214213
215214 try {
216- if ( downloadPath . endsWith ( ".tar.gz" ) ) {
217- downloadPath = await this . extractTar ( response , downloadPath )
218- } else {
219- downloadPath = await this . extractZip ( response , downloadPath )
220- }
215+ downloadPath = await this . extractTar ( response , downloadPath )
221216 logger . debug ( "Downloaded update" , field ( "path" , downloadPath ) )
222217
223218 // The archive should have a directory inside at the top level with the
@@ -275,40 +270,6 @@ export class UpdateHttpProvider extends HttpProvider {
275270 return downloadPath
276271 }
277272
278- private async extractZip ( response : Readable , downloadPath : string ) : Promise < string > {
279- logger . debug ( "Downloading zip" , field ( "path" , downloadPath ) )
280-
281- response . pause ( )
282- await fs . remove ( downloadPath )
283-
284- const write = fs . createWriteStream ( downloadPath )
285- response . pipe ( write )
286- response . on ( "error" , ( error ) => write . destroy ( error ) )
287- response . on ( "close" , ( ) => write . end ( ) )
288-
289- await new Promise ( ( resolve , reject ) => {
290- write . on ( "error" , reject )
291- write . on ( "close" , resolve )
292- response . resume
293- } )
294-
295- const zipPath = downloadPath
296- downloadPath = downloadPath . replace ( / \. z i p $ / , "" )
297- await fs . remove ( downloadPath )
298-
299- logger . debug ( "Extracting zip" , field ( "path" , zipPath ) )
300-
301- await new Promise ( ( resolve , reject ) => {
302- new zip ( zipPath ) . extractAllToAsync ( downloadPath , true , ( error ) => {
303- return error ? reject ( error ) : resolve ( )
304- } )
305- } )
306-
307- await fs . remove ( zipPath )
308-
309- return downloadPath
310- }
311-
312273 /**
313274 * Given an update return the name for the packaged archived.
314275 */
@@ -329,7 +290,7 @@ export class UpdateHttpProvider extends HttpProvider {
329290 if ( arch === "x64" ) {
330291 arch = "x86_64"
331292 }
332- return `code-server-${ update . version } -${ target } -${ arch } .${ target === "darwin" ? "zip" : " tar.gz" } `
293+ return `code-server-${ update . version } -${ target } -${ arch } .tar.gz`
333294 }
334295
335296 private async request ( uri : string ) : Promise < Buffer > {
0 commit comments