99} from 'vscode' ;
1010import * as fs from 'fs-extra' ;
1111import * as path from 'path' ;
12+
1213import { DatabaseManager , DatabaseItem } from './databases' ;
1314import {
1415 ProgressCallback ,
@@ -261,19 +262,9 @@ function validateHttpsUrl(databaseUrl: string) {
261262}
262263
263264async function readAndUnzip ( databaseUrl : string , unzipPath : string ) {
264- const unzipStream = unzipper . Extract ( {
265- path : unzipPath ,
266- } ) ;
267-
268- await new Promise ( ( resolve , reject ) => {
269- // we already know this is a file scheme
270- const databaseFile = Uri . parse ( databaseUrl ) . fsPath ;
271- const stream = fs . createReadStream ( databaseFile ) ;
272- stream . on ( 'error' , reject ) ;
273- unzipStream . on ( 'error' , reject ) ;
274- unzipStream . on ( 'close' , resolve ) ;
275- stream . pipe ( unzipStream ) ;
276- } ) ;
265+ const databaseFile = Uri . parse ( databaseUrl ) . fsPath ;
266+ const directory = await unzipper . Open . file ( databaseFile ) ;
267+ await directory . extract ( { path : unzipPath } ) ;
277268}
278269
279270async function fetchAndUnzip (
@@ -288,6 +279,7 @@ async function fetchAndUnzip(
288279 const unzipStream = unzipper . Extract ( {
289280 path : unzipPath ,
290281 } ) ;
282+
291283 progressCallback ?.( {
292284 maxStep : 3 ,
293285 message : 'Unzipping database' ,
0 commit comments