Skip to content

Commit

Permalink
fix: testproj need to be with a dot
Browse files Browse the repository at this point in the history
  • Loading branch information
reitowo committed Nov 13, 2024
1 parent fa43f4f commit 2aa0775
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions extensions/ql-vscode/src/databases/local-databases-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -980,14 +980,14 @@ export class DatabaseUI extends DisposableObject {
byFolder: boolean,
progress: ProgressCallback,
): Promise<DatabaseItem | undefined> {
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(
Expand Down Expand Up @@ -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({
Expand All @@ -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,
);
Expand All @@ -1056,7 +1066,7 @@ export class DatabaseUI extends DisposableObject {
} else {
failures.push(entry[0]);
}
} catch (e) {
} catch {
failures.push(entry[0]);
}
}
Expand Down

0 comments on commit 2aa0775

Please sign in to comment.