File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1083,6 +1083,11 @@ export class CliVersionConstraint {
10831083 */
10841084 public static CLI_VERSION_WITH_ALLOW_LIBRARY_PACKS_IN_RESOLVE_QUERIES = new SemVer ( '2.6.1' ) ;
10851085
1086+ /**
1087+ * CLI version where the `database unbundle` subcommand was introduced.
1088+ */
1089+ public static CLI_VERSION_WITH_DATABASE_UNBUNDLE = new SemVer ( '2.6.4' ) ;
1090+
10861091 constructor ( private readonly cli : CodeQLCliServer ) {
10871092 /**/
10881093 }
@@ -1114,4 +1119,9 @@ export class CliVersionConstraint {
11141119 async supportsDatabaseRegistration ( ) {
11151120 return this . isVersionAtLeast ( CliVersionConstraint . CLI_VERSION_WITH_DB_REGISTRATION ) ;
11161121 }
1122+
1123+ async supportsDatabaseUnbundle ( ) {
1124+ return this . isVersionAtLeast ( CliVersionConstraint . CLI_VERSION_WITH_DATABASE_UNBUNDLE ) ;
1125+ }
1126+
11171127}
Original file line number Diff line number Diff line change 11import fetch , { Response } from 'node-fetch' ;
22import { zip } from 'zip-a-folder' ;
3+ import * as unzipper from 'unzipper' ;
34import {
45 Uri ,
56 CancellationToken ,
67 commands ,
78 window ,
89} from 'vscode' ;
9- import { CodeQLCliServer } from './cli' ;
10+ import { CodeQLCliServer } from './cli' ;
1011import * as fs from 'fs-extra' ;
1112import * as path from 'path' ;
1213
@@ -267,10 +268,16 @@ async function readAndUnzip(
267268 step : 9 ,
268269 message : `Unzipping into ${ path . basename ( unzipPath ) } `
269270 } ) ;
270- // Must get the zip central directory since streaming the
271- // zip contents may not have correct local file headers.
272- // Instead, we can only rely on the central directory.
273- await cli . databaseUnbundle ( zipFile , unzipPath ) ;
271+ if ( cli . cliConstraints . supportsDatabaseUnbundle ( ) ) {
272+ // Use the `database unbundle` command if the installed cli version supports it
273+ await cli . databaseUnbundle ( zipFile , unzipPath ) ;
274+ } else {
275+ // Must get the zip central directory since streaming the
276+ // zip contents may not have correct local file headers.
277+ // Instead, we can only rely on the central directory.
278+ const directory = await unzipper . Open . file ( zipFile ) ;
279+ await directory . extract ( { path : unzipPath } ) ;
280+ }
274281}
275282
276283async function fetchAndUnzip (
You can’t perform that action at this time.
0 commit comments