Merge pull request #170 from Zagrios/hotfix/dotnet-notif-not-appear-sometimes

Hotfix/dotnet notif not appear sometimes
This commit is contained in:
MathieuG-P
2023-03-04 21:48:18 +01:00
committed by GitHub
2 changed files with 36 additions and 12 deletions
+19 -6
View File
@@ -1,3 +1,4 @@
/* eslint-disable prefer-promise-reject-errors */
import { BS_APP_ID, BS_DEPOT } from "../constants";
import path from "path";
import { BSVersion, PartialBSVersion } from 'shared/bs-version.interface';
@@ -10,6 +11,7 @@ import { BSLocalVersionService } from "./bs-local-version.service";
import isOnline from 'is-online';
import { WindowManagerService } from "./window-manager.service";
import { copy, copySync } from "fs-extra";
import { clean, satisfies } from "semver";
export class BSInstallerService{
@@ -70,16 +72,19 @@ export class BSInstallerService{
});
}
public async isDotNet6Installed(): Promise<boolean>{
public async isDotNet6Installed(): Promise<boolean>{
try{
const process = spawnSync(this.getDepotDownloaderExePath(), {shell: true});
const out = process.output.toString();
if(out.includes(".NET runtime can be found at")){ return false; }
if(process.stderr.toString()){
log.error("no dotnet", process.stderr.toString());
return false;
}
return true;
}
catch(e){
log.error("Error while checking .NET 6", e);
return false;
}
}
}
public async downloadBsVersion(downloadInfos: DownloadInfo): Promise<DownloadEvent>{
@@ -104,8 +109,7 @@ export class BSInstallerService{
`-depot ${BS_DEPOT}`,
`-manifest ${bsVersion.BSManifest}`,
`-username ${downloadInfos.username}`,
`-dir \"${this.localVersionService.getVersionFolder(downloadVersion)}\"`,
(downloadInfos.stay || !downloadInfos.password) && "-remember-password"
`-dir \"${this.localVersionService.getVersionFolder(downloadVersion)}\"`
],
{shell: true, cwd: this.installLocationService.versionsDirectory}
);
@@ -156,16 +160,25 @@ export class BSInstallerService{
this.downloadProcess.stdout.on('error', (err) => {
log.error("BS-DOWNLOAD ERROR", err.toString());
this.killDownloadProcess();
if(err.toString().includes(".NET") || err.toString().includes("dotnet") || err.toString().includes(".dll")){
reject("dotnet");
}
reject();
});
this.downloadProcess.stderr.on('data', (err) => {
log.error("BS-DOWNLOAD ERROR", err.toString());
this.killDownloadProcess();
if(err.toString().includes(".NET") || err.toString().includes("dotnet") || err.toString().includes(".dll")){
reject("dotnet");
}
reject();
});
this.downloadProcess.stderr.on('error', (err) => {
log.error("BS-DOWNLOAD ERROR", err.toString());
this.killDownloadProcess();
if(err.toString().includes(".NET") || err.toString().includes("dotnet") || err.toString().includes(".dll")){
reject("dotnet");
}
reject();
});
+17 -6
View File
@@ -96,11 +96,7 @@ export class BsDownloaderService{
return this.ipcService.send<boolean>("is-dotnet-6-installed").then(res => res.success && res.data)
}
public async download(bsVersion: BSVersion, isVerification?: boolean, isFirstCall = true): Promise<IpcResponse<DownloadEvent>>{
if(isFirstCall && !this.progressBarService.require()){ return {success: false}; }
if(isFirstCall && !(await this.isDotNet6Installed())){
private async showDotNetNotInstalledError(): Promise<void>{
const choice = await this.notificationService.notifyError({
duration: 11_000,
title: "notifications.bs-download.errors.titles.dotnet-required",
@@ -111,7 +107,16 @@ export class BsDownloaderService{
if(choice === "0"){
this.linkOpener.open("https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-6.0.12-windows-x64-installer");
}
}
public async download(bsVersion: BSVersion, isVerification?: boolean, isFirstCall = true): Promise<IpcResponse<DownloadEvent>>{
// TODO : to remake cause we don't need recursion anymore
if(isFirstCall && !this.progressBarService.require()){ return {success: false}; }
if(isFirstCall && !(await this.isDotNet6Installed())){
await this.showDotNetNotInstalledError();
return {success: false};
}
@@ -142,7 +147,13 @@ export class BsDownloaderService{
this.progressBarService.hide(true);
this.resetDownload();
if(res.success && isFirstCall){ this.notificationService.notifySuccess({title: `notifications.bs-download.success.titles.${isVerification ? "verification-finished" : "download-success"}`, duration: 3000}); }
else if(res.data && isFirstCall){ this.notificationService.notifyError({title: `notifications.types.error`, desc: `notifications.bs-download.errors.msg.${res.data}`, duration: 3000}); }
else if(res.data === "dotnet" && isFirstCall){
await this.showDotNetNotInstalledError();
return res;
}
else if(res.data && isFirstCall){
this.notificationService.notifyError({title: `notifications.types.error`, desc: `notifications.bs-download.errors.msg.${res.data}`, duration: 3000});
}
return res;
}