Skip to content

Commit 0e47709

Browse files
committed
Remove ignoreSourceArchive option from databases
This option was used to ignore source archives for `.testproj` databases. It is only set to `true` or `false` when creating the database and could not be changed, so I don't think we need this option. It can simply be derived from the database URI. This simplifies handling of databases a bit.
1 parent 2f61cfe commit 0e47709

File tree

5 files changed

+8
-15
lines changed

5 files changed

+8
-15
lines changed

extensions/ql-vscode/src/databases/local-databases/database-item-impl.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import * as cli from "../../codeql-cli/cli";
33
import vscode from "vscode";
44
import { FullDatabaseOptions } from "./database-options";
5-
import { basename, dirname, join, relative } from "path";
5+
import { basename, dirname, extname, join, relative } from "path";
66
import {
77
decodeSourceArchiveUri,
88
encodeArchiveBasePath,
@@ -45,13 +45,18 @@ export class DatabaseItemImpl implements DatabaseItem {
4545
}
4646

4747
public get sourceArchive(): vscode.Uri | undefined {
48-
if (this.options.ignoreSourceArchive || this.contents === undefined) {
48+
if (this.ignoreSourceArchive || this.contents === undefined) {
4949
return undefined;
5050
} else {
5151
return this.contents.sourceArchiveUri;
5252
}
5353
}
5454

55+
private get ignoreSourceArchive(): boolean {
56+
// Ignore the source archive for QLTest databases.
57+
return extname(this.databaseUri.fsPath) === ".testproj";
58+
}
59+
5560
public get dateAdded(): number | undefined {
5661
return this.options.dateAdded;
5762
}

extensions/ql-vscode/src/databases/local-databases/database-manager.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
isCodespacesTemplate,
1111
setAutogenerateQlPacks,
1212
} from "../../config";
13-
import { extname, join } from "path";
13+
import { join } from "path";
1414
import { FullDatabaseOptions } from "./database-options";
1515
import { DatabaseItemImpl } from "./database-item-impl";
1616
import {
@@ -164,10 +164,7 @@ export class DatabaseManager extends DisposableObject {
164164
displayName: string | undefined,
165165
): Promise<DatabaseItemImpl> {
166166
const contents = await DatabaseResolver.resolveDatabaseContents(uri);
167-
// Ignore the source archive for QLTest databases by default.
168-
const isQLTestDatabase = extname(uri.fsPath) === ".testproj";
169167
const fullOptions: FullDatabaseOptions = {
170-
ignoreSourceArchive: isQLTestDatabase,
171168
// If a displayName is not passed in, the basename of folder containing the database is used.
172169
displayName,
173170
dateAdded: Date.now(),
@@ -324,16 +321,12 @@ export class DatabaseManager extends DisposableObject {
324321
state: PersistedDatabaseItem,
325322
): Promise<DatabaseItemImpl> {
326323
let displayName: string | undefined = undefined;
327-
let ignoreSourceArchive = false;
328324
let dateAdded = undefined;
329325
let language = undefined;
330326
if (state.options) {
331327
if (typeof state.options.displayName === "string") {
332328
displayName = state.options.displayName;
333329
}
334-
if (typeof state.options.ignoreSourceArchive === "boolean") {
335-
ignoreSourceArchive = state.options.ignoreSourceArchive;
336-
}
337330
if (typeof state.options.dateAdded === "number") {
338331
dateAdded = state.options.dateAdded;
339332
}
@@ -347,7 +340,6 @@ export class DatabaseManager extends DisposableObject {
347340
}
348341

349342
const fullOptions: FullDatabaseOptions = {
350-
ignoreSourceArchive,
351343
displayName,
352344
dateAdded,
353345
language,
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
export interface DatabaseOptions {
22
displayName?: string;
3-
ignoreSourceArchive?: boolean;
43
dateAdded?: number | undefined;
54
language?: string;
65
}
76

87
export interface FullDatabaseOptions extends DatabaseOptions {
9-
ignoreSourceArchive: boolean;
108
dateAdded: number | undefined;
119
language: string | undefined;
1210
}

extensions/ql-vscode/test/factories/databases/databases.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { DirResult } from "tmp";
1010
export function mockDbOptions(): FullDatabaseOptions {
1111
return {
1212
dateAdded: 123,
13-
ignoreSourceArchive: false,
1413
language: "",
1514
};
1615
}

extensions/ql-vscode/test/vscode-tests/minimal-workspace/local-databases.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,6 @@ describe("local databases", () => {
634634

635635
const options: FullDatabaseOptions = {
636636
dateAdded: 123,
637-
ignoreSourceArchive: false,
638637
language,
639638
};
640639
mockDbItem = createMockDB(dir, options);

0 commit comments

Comments
 (0)