Delete withInheritedProgress because we always have a progress context
This commit is contained in:
Родитель
a559a0a3e2
Коммит
bf58e311dd
|
@ -90,24 +90,6 @@ export interface ProgressContext {
|
|||
token: CancellationToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Like `withProgress()`, except that the caller is not required to provide a progress context. If
|
||||
* the caller does provide one, any long-running operations performed by `task` will use the
|
||||
* supplied progress context. Otherwise, this function wraps `task` in a new progress context with
|
||||
* the supplied options.
|
||||
*/
|
||||
export function withInheritedProgress<R>(
|
||||
parent: ProgressContext | undefined,
|
||||
task: ProgressTask<R>,
|
||||
options: ProgressOptions,
|
||||
): Thenable<R> {
|
||||
if (parent !== undefined) {
|
||||
return task(parent.progress, parent.token);
|
||||
} else {
|
||||
return withProgress(task, options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a progress monitor that indicates how much progess has been made
|
||||
* reading from a stream.
|
||||
|
|
|
@ -16,7 +16,6 @@ import {
|
|||
ThemeIcon,
|
||||
ThemeColor,
|
||||
workspace,
|
||||
ProgressLocation,
|
||||
} from "vscode";
|
||||
import { pathExists, stat, readdir, remove } from "fs-extra";
|
||||
|
||||
|
@ -31,7 +30,6 @@ import type {
|
|||
} from "../common/vscode/progress";
|
||||
import {
|
||||
UserCancellationException,
|
||||
withInheritedProgress,
|
||||
withProgress,
|
||||
} from "../common/vscode/progress";
|
||||
import {
|
||||
|
@ -330,10 +328,9 @@ export class DatabaseUI extends DisposableObject {
|
|||
|
||||
private async chooseDatabaseFolder(
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
): Promise<void> {
|
||||
try {
|
||||
await this.chooseAndSetDatabase(true, { progress, token });
|
||||
await this.chooseAndSetDatabase(true, progress);
|
||||
} catch (e) {
|
||||
void showAndLogExceptionWithTelemetry(
|
||||
this.app.logger,
|
||||
|
@ -347,8 +344,8 @@ export class DatabaseUI extends DisposableObject {
|
|||
|
||||
private async handleChooseDatabaseFolder(): Promise<void> {
|
||||
return withProgress(
|
||||
async (progress, token) => {
|
||||
await this.chooseDatabaseFolder(progress, token);
|
||||
async (progress) => {
|
||||
await this.chooseDatabaseFolder(progress);
|
||||
},
|
||||
{
|
||||
title: "Adding database from folder",
|
||||
|
@ -358,8 +355,8 @@ export class DatabaseUI extends DisposableObject {
|
|||
|
||||
private async handleChooseDatabaseFolderFromPalette(): Promise<void> {
|
||||
return withProgress(
|
||||
async (progress, token) => {
|
||||
await this.chooseDatabaseFolder(progress, token);
|
||||
async (progress) => {
|
||||
await this.chooseDatabaseFolder(progress);
|
||||
},
|
||||
{
|
||||
title: "Choose a Database from a Folder",
|
||||
|
@ -500,10 +497,9 @@ export class DatabaseUI extends DisposableObject {
|
|||
|
||||
private async chooseDatabaseArchive(
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
): Promise<void> {
|
||||
try {
|
||||
await this.chooseAndSetDatabase(false, { progress, token });
|
||||
await this.chooseAndSetDatabase(false, progress);
|
||||
} catch (e: unknown) {
|
||||
void showAndLogExceptionWithTelemetry(
|
||||
this.app.logger,
|
||||
|
@ -517,8 +513,8 @@ export class DatabaseUI extends DisposableObject {
|
|||
|
||||
private async handleChooseDatabaseArchive(): Promise<void> {
|
||||
return withProgress(
|
||||
async (progress, token) => {
|
||||
await this.chooseDatabaseArchive(progress, token);
|
||||
async (progress) => {
|
||||
await this.chooseDatabaseArchive(progress);
|
||||
},
|
||||
{
|
||||
title: "Adding database from archive",
|
||||
|
@ -528,8 +524,8 @@ export class DatabaseUI extends DisposableObject {
|
|||
|
||||
private async handleChooseDatabaseArchiveFromPalette(): Promise<void> {
|
||||
return withProgress(
|
||||
async (progress, token) => {
|
||||
await this.chooseDatabaseArchive(progress, token);
|
||||
async (progress) => {
|
||||
await this.chooseDatabaseArchive(progress);
|
||||
},
|
||||
{
|
||||
title: "Choose a Database from an Archive",
|
||||
|
@ -940,41 +936,31 @@ export class DatabaseUI extends DisposableObject {
|
|||
*/
|
||||
private async chooseAndSetDatabase(
|
||||
byFolder: boolean,
|
||||
progress: ProgressContext | undefined,
|
||||
progress: ProgressCallback,
|
||||
): Promise<DatabaseItem | undefined> {
|
||||
const uri = await chooseDatabaseDir(byFolder);
|
||||
if (!uri) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return await withInheritedProgress(
|
||||
progress,
|
||||
async (progress) => {
|
||||
if (byFolder) {
|
||||
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. Must unzip into a workspace-controlled area
|
||||
// before importing.
|
||||
return await importArchiveDatabase(
|
||||
this.app.commands,
|
||||
uri.toString(true),
|
||||
this.databaseManager,
|
||||
this.storagePath,
|
||||
progress,
|
||||
this.queryServer.cliServer,
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
location: ProgressLocation.Notification,
|
||||
cancellable: true,
|
||||
title: "Opening database",
|
||||
},
|
||||
);
|
||||
if (byFolder) {
|
||||
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. Must unzip into a workspace-controlled area
|
||||
// before importing.
|
||||
return await importArchiveDatabase(
|
||||
this.app.commands,
|
||||
uri.toString(true),
|
||||
this.databaseManager,
|
||||
this.storagePath,
|
||||
progress,
|
||||
this.queryServer.cliServer,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче