Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handling win installer exit code #12

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/install/base-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export abstract class BaseInstaller implements Installer {
abstract getPreflightChecks(): extensionApi.InstallCheck[];

async downloadSha(installerUrl: string, fileName: string): Promise<string> {
console.info('Download SHA sums...');
const shaSumUrl = installerUrl.substring(0, installerUrl.lastIndexOf('/')) + '/sha256sum.txt';
const shaSumContentResponse = await got.get(shaSumUrl);

Expand All @@ -104,15 +103,12 @@ export abstract class BaseInstaller implements Installer {

async downloadCrcInstaller(installerUrl: string, destinationPath: string, fileSha: string): Promise<void> {
let lastProgressStr = '';

this.statusBarItem.text = 'Downloading';
const downloadStream = got.stream(installerUrl);


downloadStream.on('downloadProgress', (progress) => {
const progressStr = /* progress.transferred + ' of ' + progress.total + ' ' + */Math.round(progress.percent * 100) + '%';
const progressStr = /* progress.transferred + ' of ' + progress.total + ' ' + */Math.round(progress.percent * 100) + '%';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no actual change....

if(lastProgressStr !== progressStr) {
//TODO: show progress on UI!
this.statusBarItem.text = 'Downloading: ' + progressStr;
}
});
Expand All @@ -129,7 +125,7 @@ export abstract class BaseInstaller implements Installer {

protected async downloadAndCheckInstaller(installerUrl: string, installerFileName: string): Promise<string> {
this.createStatusBar();
this.statusBarItem.text = 'Downloading SHA...'
this.statusBarItem.text = 'Downloading: 0%';
const sha = await this.downloadSha(installerUrl, installerFileName);

const installerFolder = path.resolve(os.tmpdir(), 'crc-extension');
Expand Down
2 changes: 2 additions & 0 deletions src/install/win-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export class WinInstall extends BaseInstaller {
'OK',
);
return true;
} else if(runResult.exitCode === 1602) { // user cancel installation
return false;
} else {
throw new Error(runResult.stdErr);
}
Expand Down