Skip to content

Commit 3288572

Browse files
committed
Don't add database source archive folders by default
1 parent bc2847a commit 3288572

4 files changed

Lines changed: 23 additions & 8 deletions

File tree

extensions/ql-vscode/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,12 @@
378378
"codeQL.databaseDownload.allowHttp": {
379379
"type": "boolean",
380380
"default": false,
381-
"description": "Allow database to be downloaded via HTTP. Warning: enabling this option will allow downloading from insecure servers."
381+
"description": "Allow databases to be downloaded via HTTP. Warning: enabling this option will allow downloading from insecure servers."
382+
},
383+
"codeQL.databaseDownload.addDatabaseSourceToWorkspace": {
384+
"type": "boolean",
385+
"default": false,
386+
"markdownDescription": "When downloading a database, automatically add the database's source folder as a workspace folder. Warning: enabling this option in a single-folder workspace will cause the workspace to reload as a [multi-root workspace](https://code.visualstudio.com/docs/editor/multi-root-workspaces). This may cause query history and database lists to be reset."
382387
}
383388
}
384389
},

extensions/ql-vscode/src/config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,15 @@ export function allowHttp(): boolean {
649649
return ALLOW_HTTP_SETTING.getValue<boolean>() || false;
650650
}
651651

652+
const ADD_DATABASE_SOURCE_TO_WORKSPACE_SETTING = new Setting(
653+
"addDatabaseSourceToWorkspace",
654+
DATABASE_DOWNLOAD_SETTING,
655+
);
656+
657+
export function addDatabaseSourceToWorkspace(): boolean {
658+
return ADD_DATABASE_SOURCE_TO_WORKSPACE_SETTING.getValue<boolean>() || false;
659+
}
660+
652661
/**
653662
* Parent setting for all settings related to the "Create Query" command.
654663
*/

extensions/ql-vscode/src/databases/database-fetcher.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
} from "../common/github-url-identifier-helper";
3030
import { Credentials } from "../common/authentication";
3131
import { AppCommandManager } from "../common/commands";
32-
import { allowHttp } from "../config";
32+
import { addDatabaseSourceToWorkspace, allowHttp } from "../config";
3333
import { showAndLogInformationMessage } from "../common/logging";
3434
import { AppOctokit } from "../common/octokit";
3535
import { getLanguageDisplayName } from "../common/query-language";
@@ -99,7 +99,7 @@ export async function promptImportGithubDatabase(
9999
cli?: CodeQLCliServer,
100100
language?: string,
101101
makeSelected = true,
102-
addSourceArchiveFolder = true,
102+
addSourceArchiveFolder = addDatabaseSourceToWorkspace(),
103103
): Promise<DatabaseItem | undefined> {
104104
const githubRepo = await askForGitHubRepo(progress);
105105
if (!githubRepo) {
@@ -178,7 +178,7 @@ export async function downloadGitHubDatabase(
178178
cli?: CodeQLCliServer,
179179
language?: string,
180180
makeSelected = true,
181-
addSourceArchiveFolder = true,
181+
addSourceArchiveFolder = addDatabaseSourceToWorkspace(),
182182
): Promise<DatabaseItem | undefined> {
183183
const nwo = getNwoFromGitHubUrl(githubRepo) || githubRepo;
184184
if (!isValidGitHubNwo(nwo)) {
@@ -295,7 +295,7 @@ async function databaseArchiveFetcher(
295295
progress: ProgressCallback,
296296
cli?: CodeQLCliServer,
297297
makeSelected = true,
298-
addSourceArchiveFolder = true,
298+
addSourceArchiveFolder = addDatabaseSourceToWorkspace(),
299299
): Promise<DatabaseItem> {
300300
progress({
301301
message: "Getting database",
@@ -476,7 +476,7 @@ async function checkForFailingResponse(
476476
return response;
477477
}
478478

479-
// An error downloading the database. Attempt to extract the resaon behind it.
479+
// An error downloading the database. Attempt to extract the reason behind it.
480480
const text = await response.text();
481481
let msg: string;
482482
try {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { QueryRunner } from "../../query-server";
77
import * as cli from "../../codeql-cli/cli";
88
import { ProgressCallback, withProgress } from "../../common/vscode/progress";
99
import {
10+
addDatabaseSourceToWorkspace,
1011
getAutogenerateQlPacks,
1112
isCodespacesTemplate,
1213
setAutogenerateQlPacks,
@@ -135,7 +136,7 @@ export class DatabaseManager extends DisposableObject {
135136
displayName?: string,
136137
{
137138
isTutorialDatabase = false,
138-
addSourceArchiveFolder = true,
139+
addSourceArchiveFolder = addDatabaseSourceToWorkspace(),
139140
}: OpenDatabaseOptions = {},
140141
): Promise<DatabaseItem> {
141142
const databaseItem = await this.createDatabaseItem(uri, displayName);
@@ -158,7 +159,7 @@ export class DatabaseManager extends DisposableObject {
158159
databaseItem: DatabaseItemImpl,
159160
makeSelected: boolean,
160161
isTutorialDatabase?: boolean,
161-
addSourceArchiveFolder = true,
162+
addSourceArchiveFolder = addDatabaseSourceToWorkspace(),
162163
): Promise<DatabaseItem> {
163164
const existingItem = this.findDatabaseItem(databaseItem.databaseUri);
164165
if (existingItem !== undefined) {

0 commit comments

Comments
 (0)