From 2aa0775073b164d0ba0aaf9b52bc22cdb505d511 Mon Sep 17 00:00:00 2001 From: reito Date: Thu, 14 Nov 2024 00:59:02 +0800 Subject: [PATCH] fix: testproj need to be with a dot --- .../src/databases/local-databases-ui.ts | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/extensions/ql-vscode/src/databases/local-databases-ui.ts b/extensions/ql-vscode/src/databases/local-databases-ui.ts index a28a02a18a1..dfff074f661 100644 --- a/extensions/ql-vscode/src/databases/local-databases-ui.ts +++ b/extensions/ql-vscode/src/databases/local-databases-ui.ts @@ -980,14 +980,14 @@ export class DatabaseUI extends DisposableObject { byFolder: boolean, progress: ProgressCallback, ): Promise { - if (byFolder && !uri.fsPath.endsWith("testproj")) { + if (byFolder && !uri.fsPath.endsWith(".testproj")) { const fixedUri = await this.fixDbUri(uri); // we are selecting a database folder return await this.databaseManager.openDatabase(fixedUri, { type: "folder", }); } else { - // we are selecting a database archive or a testproj. + // we are selecting a database archive or a .testproj. // Unzip archives (if an archive) and copy into a workspace-controlled area // before importing. return await this.databaseFetcher.importLocalDatabase( @@ -1028,6 +1028,7 @@ export class DatabaseUI extends DisposableObject { const databases: DatabaseItem[] = []; const failures: string[] = []; const entries = await workspace.fs.readDirectory(uri); + const validFileTypes = [FileType.File, FileType.Directory]; for (const [index, entry] of entries.entries()) { progress({ @@ -1044,10 +1045,19 @@ export class DatabaseUI extends DisposableObject { }); }; + if (!validFileTypes.includes(entry[1])) { + void this.app.logger.log( + `Skip import ${entry}, invalid FileType: ${entry[1]}`, + ); + continue; + } + try { - const fixedUri = await this.fixDbUri(Uri.joinPath(uri, entry[0])); + const databaseUri = Uri.joinPath(uri, entry[0]); + void this.app.logger.log(`Importing from ${databaseUri}`); + const database = await this.importDatabase( - fixedUri, + databaseUri, entry[1] === FileType.Directory, subProgress, ); @@ -1056,7 +1066,7 @@ export class DatabaseUI extends DisposableObject { } else { failures.push(entry[0]); } - } catch (e) { + } catch { failures.push(entry[0]); } }