1
1
import { field , logger } from "@coder/logger"
2
- import zip from "adm-zip"
3
2
import * as cp from "child_process"
4
3
import * as fs from "fs-extra"
5
4
import * as http from "http"
@@ -213,11 +212,7 @@ export class UpdateHttpProvider extends HttpProvider {
213
212
const response = await this . requestResponse ( url )
214
213
215
214
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 )
221
216
logger . debug ( "Downloaded update" , field ( "path" , downloadPath ) )
222
217
223
218
// The archive should have a directory inside at the top level with the
@@ -275,40 +270,6 @@ export class UpdateHttpProvider extends HttpProvider {
275
270
return downloadPath
276
271
}
277
272
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
-
312
273
/**
313
274
* Given an update return the name for the packaged archived.
314
275
*/
@@ -329,7 +290,7 @@ export class UpdateHttpProvider extends HttpProvider {
329
290
if ( arch === "x64" ) {
330
291
arch = "x86_64"
331
292
}
332
- return `code-server-${ update . version } -${ target } -${ arch } .${ target === "darwin" ? "zip" : " tar.gz" } `
293
+ return `code-server-${ update . version } -${ target } -${ arch } .tar.gz`
333
294
}
334
295
335
296
private async request ( uri : string ) : Promise < Buffer > {
0 commit comments