Skip to content

Commit e66ad99

Browse files
committed
Download databases into extension storage path
Now that we've figured out how to set the storage path for both Mac & Windows, we also want to make sure we're consistent with the location where we save databases. At the moment, our change will download databases directly in the workspace folder. When we call `downloadGitHubDatabase()` in other places outside the wizard, we provide `ctx.storageUri.fsPath` as the location. [1] [2] [3] Let's do the same here. I've tested this on Mac for the codespaces-codeql & starter workspaces. [1]: https://github.com/github/vscode-codeql/blob/c7bb22c312d4bbe46d90ff0a43e9cff22c6bd5ed/extensions/ql-vscode/src/local-databases-ui.ts#L476 [2]: https://github.com/github/vscode-codeql/blob/c7bb22c312d4bbe46d90ff0a43e9cff22c6bd5ed/extensions/ql-vscode/src/extension.ts#L710 [3]: https://github.com/github/vscode-codeql/blob/c7bb22c312d4bbe46d90ff0a43e9cff22c6bd5ed/extensions/ql-vscode/src/extension.ts#L1120 [4]:
1 parent 517a053 commit e66ad99

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

extensions/ql-vscode/src/extension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,7 @@ async function activateWithInstalledDistribution(
862862
databaseUI,
863863
localQueryResultsView,
864864
queryStorageDir,
865+
ctx,
865866
);
866867
ctx.subscriptions.push(localQueries);
867868

extensions/ql-vscode/src/local-queries.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ProgressCallback, ProgressUpdate, withProgress } from "./progress";
22
import {
33
CancellationToken,
44
CancellationTokenSource,
5+
ExtensionContext,
56
QuickPickItem,
67
Range,
78
Uri,
@@ -221,6 +222,7 @@ export class LocalQueries extends DisposableObject {
221222
private readonly databaseUI: DatabaseUI,
222223
private readonly localQueryResultsView: ResultsView,
223224
private readonly queryStorageDir: string,
225+
private readonly ctx: ExtensionContext,
224226
) {
225227
super();
226228
}
@@ -381,13 +383,16 @@ export class LocalQueries extends DisposableObject {
381383
await withProgress(
382384
async (progress: ProgressCallback, token: CancellationToken) => {
383385
const credentials = isCanary() ? this.app.credentials : undefined;
386+
const contextStoragePath =
387+
this.ctx.storageUri?.fsPath || this.ctx.globalStorageUri.fsPath;
384388
const skeletonQueryWizard = new SkeletonQueryWizard(
385389
this.cliServer,
386390
progress,
387391
credentials,
388392
extLogger,
389393
this.databaseManager,
390394
token,
395+
contextStoragePath,
391396
);
392397
await skeletonQueryWizard.execute();
393398
},

extensions/ql-vscode/src/skeleton-query-wizard.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export class SkeletonQueryWizard {
3636
private readonly extLogger: OutputChannelLogger,
3737
private readonly databaseManager: DatabaseManager,
3838
private readonly token: CancellationToken,
39+
private readonly databaseStoragePath: string | undefined,
3940
) {}
4041

4142
private get folderName() {
@@ -197,6 +198,10 @@ export class SkeletonQueryWizard {
197198
throw new Error("Workspace storage path is undefined");
198199
}
199200

201+
if (this.databaseStoragePath === undefined) {
202+
throw new Error("Database storage path is undefined");
203+
}
204+
200205
if (this.language === undefined) {
201206
throw new Error("Language is undefined");
202207
}
@@ -220,7 +225,7 @@ export class SkeletonQueryWizard {
220225
await databaseFetcher.downloadGitHubDatabase(
221226
chosenRepo,
222227
this.databaseManager,
223-
this.qlPackStoragePath,
228+
this.databaseStoragePath,
224229
this.credentials,
225230
this.progress,
226231
this.token,

extensions/ql-vscode/test/vscode-tests/cli-integration/skeleton-query-wizard.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ describe("SkeletonQueryWizard", () => {
114114
extLogger,
115115
mockDatabaseManager,
116116
token,
117+
storagePath,
117118
);
118119

119120
askForGitHubRepoSpy = jest
@@ -244,6 +245,7 @@ describe("SkeletonQueryWizard", () => {
244245
extLogger,
245246
mockDatabaseManagerWithItems,
246247
token,
248+
storagePath,
247249
);
248250
});
249251

@@ -317,6 +319,7 @@ describe("SkeletonQueryWizard", () => {
317319
extLogger,
318320
mockDatabaseManager,
319321
token,
322+
storagePath,
320323
);
321324

322325
expect(wizard.getFirstStoragePath()).toEqual("codespaces-codeql");
@@ -352,6 +355,7 @@ describe("SkeletonQueryWizard", () => {
352355
extLogger,
353356
mockDatabaseManager,
354357
token,
358+
storagePath,
355359
);
356360

357361
expect(wizard.getFirstStoragePath()).toEqual("vscode-codeql-starter");

0 commit comments

Comments
 (0)