mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Improve performance of tools table painting for bdc deployment tools (#8628)
* get tool status at tool construction * review feedback
This commit is contained in:
@@ -41,6 +41,7 @@ export const messageByDependencyType: Map<dependencyType, string> = new Map<depe
|
|||||||
|
|
||||||
export abstract class ToolBase implements ITool {
|
export abstract class ToolBase implements ITool {
|
||||||
constructor(private _platformService: IPlatformService) {
|
constructor(private _platformService: IPlatformService) {
|
||||||
|
this.startVersionAndStatusUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract name: string;
|
abstract name: string;
|
||||||
@@ -180,7 +181,8 @@ export abstract class ToolBase implements ITool {
|
|||||||
this.status = ToolStatus.Installing;
|
this.status = ToolStatus.Installing;
|
||||||
await this.installCore();
|
await this.installCore();
|
||||||
await this.addInstallationSearchPathsToSystemPath();
|
await this.addInstallationSearchPathsToSystemPath();
|
||||||
this.status = await this.updateVersionAndGetStatus();
|
this.startVersionAndStatusUpdate();
|
||||||
|
await this._pendingVersionAndStatusUpdate;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage = getErrorMessage(error);
|
const errorMessage = getErrorMessage(error);
|
||||||
this._statusDescription = localize('toolBase.InstallError', "Error installing tool '{0}' [ {1} ].{2}Error: {3}{2}See output channel '{4}' for more details", this.displayName, this.homePage, EOL, errorMessage, this.outputChannelName);
|
this._statusDescription = localize('toolBase.InstallError', "Error installing tool '{0}' [ {1} ].{2}Error: {3}{2}See output channel '{4}' for more details", this.displayName, this.homePage, EOL, errorMessage, this.outputChannelName);
|
||||||
@@ -190,7 +192,7 @@ export abstract class ToolBase implements ITool {
|
|||||||
|
|
||||||
// Since we just completed installation, the status should be ToolStatus.Installed
|
// Since we just completed installation, the status should be ToolStatus.Installed
|
||||||
// but if it is ToolStatus.NotInstalled then it means that installation failed with 0 exit code.
|
// but if it is ToolStatus.NotInstalled then it means that installation failed with 0 exit code.
|
||||||
if (this.status === ToolStatus.NotInstalled) {
|
if ((this.status as ToolStatus) === ToolStatus.NotInstalled) {
|
||||||
this._statusDescription = localize('toolBase.InstallFailed', "Installation commands completed but version of tool '{0}' could not be detected so our installation attempt has failed. Detection Error: {1}{2}Cleaning up previous installations would help.", this.displayName, this._statusDescription, EOL);
|
this._statusDescription = localize('toolBase.InstallFailed', "Installation commands completed but version of tool '{0}' could not be detected so our installation attempt has failed. Detection Error: {1}{2}Cleaning up previous installations would help.", this.displayName, this._statusDescription, EOL);
|
||||||
if (this.uninstallCommand) {
|
if (this.uninstallCommand) {
|
||||||
this._statusDescription += localize('toolBase.ManualUninstallCommand', " A possibly way to uninstall is using this command:{0} >{1}", EOL, this.uninstallCommand);
|
this._statusDescription += localize('toolBase.ManualUninstallCommand', " A possibly way to uninstall is using this command:{0} >{1}", EOL, this.uninstallCommand);
|
||||||
@@ -234,13 +236,17 @@ export abstract class ToolBase implements ITool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async loadInformation(): Promise<void> {
|
public async loadInformation(): Promise<void> {
|
||||||
|
await this._pendingVersionAndStatusUpdate;
|
||||||
if (this.status === ToolStatus.NotInstalled) {
|
if (this.status === ToolStatus.NotInstalled) {
|
||||||
await this.addInstallationSearchPathsToSystemPath();
|
await this.addInstallationSearchPathsToSystemPath();
|
||||||
this.status = await this.updateVersionAndGetStatus();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async updateVersionAndGetStatus(): Promise<ToolStatus> {
|
private startVersionAndStatusUpdate() {
|
||||||
|
this._pendingVersionAndStatusUpdate = this.updateVersionAndStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async updateVersionAndStatus(): Promise<void> {
|
||||||
this._statusDescription = '';
|
this._statusDescription = '';
|
||||||
const commandOutput = await this._platformService.runCommand(
|
const commandOutput = await this._platformService.runCommand(
|
||||||
this.versionCommand.command,
|
this.versionCommand.command,
|
||||||
@@ -257,11 +263,11 @@ export abstract class ToolBase implements ITool {
|
|||||||
// discover and set the installationPath
|
// discover and set the installationPath
|
||||||
await this.setInstallationPath();
|
await this.setInstallationPath();
|
||||||
}
|
}
|
||||||
return ToolStatus.Installed;
|
this.status = ToolStatus.Installed;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this._statusDescription = localize('deployCluster.GetToolVersionError', "Error retrieving version information.{0}Invalid output received, get version command output: '{1}' ", EOL, commandOutput);
|
this._statusDescription = localize('deployCluster.GetToolVersionError', "Error retrieving version information.{0}Invalid output received, get version command output: '{1}' ", EOL, commandOutput);
|
||||||
return ToolStatus.NotInstalled;
|
this.status = ToolStatus.NotInstalled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,6 +303,7 @@ export abstract class ToolBase implements ITool {
|
|||||||
return !version || (this._version ? SemVerCompare(this._version, version) >= 0 : false);
|
return !version || (this._version ? SemVerCompare(this._version, version) >= 0 : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _pendingVersionAndStatusUpdate!: Promise<void>;
|
||||||
private _status: ToolStatus = ToolStatus.NotInstalled;
|
private _status: ToolStatus = ToolStatus.NotInstalled;
|
||||||
private _version?: SemVer;
|
private _version?: SemVer;
|
||||||
private _statusDescription?: string;
|
private _statusDescription?: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user