File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed
extensions/ql-vscode/src/databases Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -666,7 +666,9 @@ function isFile(databaseUrl: string) {
666666 *
667667 * @param databasePath The full path to the unzipped database
668668 */
669- async function ensureZippedSourceLocation ( databasePath : string ) : Promise < void > {
669+ export async function ensureZippedSourceLocation (
670+ databasePath : string ,
671+ ) : Promise < void > {
670672 const srcFolderPath = join ( databasePath , "src" ) ;
671673 const srcZipPath = `${ srcFolderPath } .zip` ;
672674
Original file line number Diff line number Diff line change @@ -995,14 +995,15 @@ export class DatabaseUI extends DisposableObject {
995995 return undefined ;
996996 }
997997
998- if ( byFolder ) {
998+ if ( byFolder && ! uri . fsPath . endsWith ( "testproj" ) ) {
999999 const fixedUri = await this . fixDbUri ( uri ) ;
10001000 // we are selecting a database folder
10011001 return await this . databaseManager . openDatabase ( fixedUri , {
10021002 type : "folder" ,
10031003 } ) ;
10041004 } else {
1005- // we are selecting a database archive. Must unzip into a workspace-controlled area
1005+ // we are selecting a database archive or a testproj.
1006+ // Unzip archives (if an archive) and copy into a workspace-controlled area
10061007 // before importing.
10071008 return await importLocalDatabase (
10081009 this . app . commands ,
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ import { DatabaseResolver } from "./database-resolver";
4343import { telemetryListener } from "../../common/vscode/telemetry" ;
4444import type { LanguageContextStore } from "../../language-context-store" ;
4545import type { DatabaseOrigin } from "./database-origin" ;
46+ import { ensureZippedSourceLocation } from "../database-fetcher" ;
4647
4748/**
4849 * The name of the key in the workspaceState dictionary in which we
@@ -227,8 +228,16 @@ export class DatabaseManager extends DisposableObject {
227228 "codeql-database.yml" ,
228229 ) ;
229230
231+ let originStat ;
232+ try {
233+ originStat = await stat ( originDbYml ) ;
234+ } catch ( e ) {
235+ // if there is an error here, assume that the origin database
236+ // is no longer available. Safely ignore and do not try to re-import.
237+ return false ;
238+ }
239+
230240 try {
231- const originStat = await stat ( originDbYml ) ;
232241 const importedStat = await stat ( importedDbYml ) ;
233242 return originStat . mtimeMs > importedStat . mtimeMs ;
234243 } catch ( e ) {
@@ -252,6 +261,7 @@ export class DatabaseManager extends DisposableObject {
252261
253262 await this . removeDatabaseItem ( dbItem ) ;
254263 await copy ( dbItem . origin . path , databaseUri . fsPath ) ;
264+ await ensureZippedSourceLocation ( databaseUri . fsPath ) ;
255265 const newDbItem = new DatabaseItemImpl ( databaseUri , dbItem . contents , {
256266 dateAdded : Date . now ( ) ,
257267 language : dbItem . language ,
You can’t perform that action at this time.
0 commit comments