Skip to content

Commit 25bac72

Browse files
committed
Use Open instead of Extract to open zip files
This allows opening zip files whose local headers are not correct.
1 parent e7ee1f8 commit 25bac72

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

extensions/ql-vscode/src/databaseFetcher.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from 'vscode';
1010
import * as fs from 'fs-extra';
1111
import * as path from 'path';
12+
1213
import { DatabaseManager, DatabaseItem } from './databases';
1314
import {
1415
ProgressCallback,
@@ -261,19 +262,9 @@ function validateHttpsUrl(databaseUrl: string) {
261262
}
262263

263264
async 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

279270
async 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

Comments
 (0)