diff --git a/src/main/ipcs/bs-download-ipcs.ts b/src/main/ipcs/bs-download-ipcs.ts index 761bfb21..77efef2d 100644 --- a/src/main/ipcs/bs-download-ipcs.ts +++ b/src/main/ipcs/bs-download-ipcs.ts @@ -1,6 +1,5 @@ import { ipcMain } from 'electron'; -import { BSVersion } from 'shared/bs-version.interface'; -import { BSInstallerService, DownloadEventType } from '../services/bs-installer.service'; +import { BSInstallerService, DownloadEventType, DownloadInfo } from '../services/bs-installer.service'; import { IpcRequest } from 'shared/models/ipc'; import { InstallationLocationService } from '../services/installation-location.service'; import { UtilsService } from '../services/utils.service'; @@ -18,13 +17,6 @@ export interface InitDownloadInfoInterface { stay: boolean } -export interface DownloadInfo { - bsVersion: BSVersion, - username: string, - password?: string, - stay?: boolean -} - ipcMain.on('is-dotnet-6-installed', async (event, request: IpcRequest) => { const installer = BSInstallerService.getInstance(); const utils = UtilsService.getInstance(); diff --git a/src/main/services/bs-installer.service.ts b/src/main/services/bs-installer.service.ts index 82f828e3..39ba74e1 100644 --- a/src/main/services/bs-installer.service.ts +++ b/src/main/services/bs-installer.service.ts @@ -87,7 +87,9 @@ export class BSInstallerService{ this.utils.createFolderIfNotExist(this.installLocationService.versionsDirectory); - const dest = this.getPathNotAleardyExist(await this.localVersionService.getVersionPath(bsVersion)); + const versionPath = await this.localVersionService.getVersionPath(bsVersion) + + const dest = !downloadInfos.isVerification ? this.getPathNotAleardyExist(versionPath) : versionPath; const downloadVersion: BSVersion = {...downloadInfos.bsVersion, ...(path.basename(dest) !== downloadInfos.bsVersion.BSVersion && {name: path.basename(dest)})} @@ -204,7 +206,8 @@ export interface DownloadInfo { bsVersion: BSVersion, username: string, password?: string, - stay?: boolean + stay?: boolean, + isVerification: boolean } export interface DownloadEvent{ diff --git a/src/renderer/components/nav-bar/nav-bar-items/bs-version-item.component.tsx b/src/renderer/components/nav-bar/nav-bar-items/bs-version-item.component.tsx index 3a1c6685..04125ce2 100644 --- a/src/renderer/components/nav-bar/nav-bar-items/bs-version-item.component.tsx +++ b/src/renderer/components/nav-bar/nav-bar-items/bs-version-item.component.tsx @@ -43,9 +43,12 @@ export function BsVersionItem(props: {version: BSVersion}) { const cancel = () => { const versionDownload = downloaderService.currentBsVersionDownload$.value; + const wasVerification = downloaderService.isVerification; downloaderService.cancelDownload().then(async res => { if(!res.success){ return; } - bsUninstallerService.uninstall(versionDownload).then(res => res && verionManagerService.askInstalledVersions()); + if(!wasVerification){ + bsUninstallerService.uninstall(versionDownload).then(res => res && verionManagerService.askInstalledVersions()); + } }); } diff --git a/src/renderer/services/bs-downloader.service.ts b/src/renderer/services/bs-downloader.service.ts index 155c7ce0..e1e4843a 100644 --- a/src/renderer/services/bs-downloader.service.ts +++ b/src/renderer/services/bs-downloader.service.ts @@ -1,4 +1,4 @@ -import { DownloadEvent } from 'main/services/bs-installer.service'; +import { DownloadEvent, DownloadInfo } from 'main/services/bs-installer.service'; import { BehaviorSubject } from 'rxjs'; import { distinctUntilChanged, filter, throttleTime } from 'rxjs/operators'; import { IpcResponse } from 'shared/models/ipc'; @@ -25,6 +25,8 @@ export class BsDownloaderService{ private readonly notificationService: NotificationService; private readonly linkOpener: LinkOpenerService; + private _isVerification: boolean = false; + public readonly currentBsVersionDownload$: BehaviorSubject = new BehaviorSubject(null); public readonly downloadProgress$: BehaviorSubject = new BehaviorSubject(0); public readonly selectedBsVersion$: BehaviorSubject = new BehaviorSubject(null); @@ -94,7 +96,7 @@ export class BsDownloaderService{ return this.ipcService.send("is-dotnet-6-installed").then(res => res.success && res.data) } - public async download(bsVersion: BSVersion, isFirstCall = true): Promise>{ + public async download(bsVersion: BSVersion, isVerification?: boolean, isFirstCall = true): Promise>{ if(isFirstCall && !this.progressBarService.require()){ return {success: false}; } if(isFirstCall && !(await this.isDotNet6Installed())){ @@ -114,6 +116,7 @@ export class BsDownloaderService{ } this.progressBarService.show(this.downloadProgress$); + this._isVerification = isVerification; let promise; if(!this.authService.sessionExist()){ @@ -123,22 +126,22 @@ export class BsDownloaderService{ return {success: false}; } this.authService.setSteamSession(res.data.username, res.data.stay); - promise = this.ipcService.send('bs-download.start', {args: {bsVersion, username: res.data.username, password: res.data.password, stay: res.data.stay}}); + promise = this.ipcService.send('bs-download.start', {args: {bsVersion, username: res.data.username, password: res.data.password, stay: res.data.stay, isVerification}}); } else{ - promise = this.ipcService.send('bs-download.start', {args: {bsVersion, username: this.authService.getSteamUsername()}}); + promise = this.ipcService.send('bs-download.start', {args: {bsVersion, username: this.authService.getSteamUsername(), isVerification}}); } let res = await promise; if(res.data?.type === "[Password]"){ this.authService.deleteSteamSession(); - res = await this.download(bsVersion, false); + res = await this.download(bsVersion, isVerification, false); } this.progressBarService.hide(true); this.resetDownload(); - if(res.success && isFirstCall){ this.notificationService.notifySuccess({title: "notifications.bs-download.success.titles.download-success", duration: 3000}); } + 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}); } return res; @@ -151,6 +154,8 @@ export class BsDownloaderService{ return res.success ? res.data : ""; } + public get isVerification(): boolean{ return this._isVerification; } + public setInstallationFolder(path: string): Promise>{ return this.ipcService.send("bs-download.set-installation-folder", {args: path}); }