mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
Merge pull request #126 from Zagrios/hotfix/no-more-files-verification-from-available-versions-list
hotfix/no-more-files-verification-from-available-versions-list
This commit is contained in:
@@ -86,6 +86,11 @@ export class BSInstallerService{
|
||||
if(!(await isOnline({timeout: 1500}))){ throw "no-internet"; }
|
||||
|
||||
this.utils.createFolderIfNotExist(this.installLocationService.versionsDirectory);
|
||||
|
||||
const dest = this.getPathNotAleardyExist(await this.localVersionService.getVersionPath(bsVersion));
|
||||
|
||||
const downloadVersion: BSVersion = {...downloadInfos.bsVersion, ...(path.basename(dest) !== downloadInfos.bsVersion.BSVersion && {name: path.basename(dest)})}
|
||||
|
||||
this.downloadProcess = spawn(
|
||||
this.getDepotDownloaderExePath(),
|
||||
[
|
||||
@@ -93,12 +98,14 @@ export class BSInstallerService{
|
||||
`-depot ${BS_DEPOT}`,
|
||||
`-manifest ${bsVersion.BSManifest}`,
|
||||
`-username ${downloadInfos.username}`,
|
||||
`-dir \"${this.localVersionService.getVersionFolder(bsVersion)}\"`,
|
||||
`-dir \"${this.localVersionService.getVersionFolder(downloadVersion)}\"`,
|
||||
(downloadInfos.stay || !downloadInfos.password) && "-remember-password"
|
||||
],
|
||||
{shell: true, cwd: this.installLocationService.versionsDirectory}
|
||||
);
|
||||
|
||||
this.utils.ipcSend("start-download-version", {success: true, data: downloadVersion});
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
this.downloadProcess.stdout.on('data', data => {
|
||||
@@ -160,22 +167,27 @@ export class BSInstallerService{
|
||||
})
|
||||
}
|
||||
|
||||
private getPathNotAleardyExist(path: string): string{
|
||||
let destPath = path;
|
||||
let folderExist = this.utils.pathExist(destPath);
|
||||
let i = 0;
|
||||
|
||||
while(folderExist){
|
||||
i++;
|
||||
destPath = `${path} (${i})`;
|
||||
folderExist = this.utils.pathExist(destPath);
|
||||
}
|
||||
|
||||
return destPath
|
||||
}
|
||||
|
||||
public async importVersion(path: string): Promise<PartialBSVersion>{
|
||||
|
||||
const rawBsVersion = await this.localVersionService.getVersionOfBSFolder(path);
|
||||
|
||||
if(!rawBsVersion){ throw new Error("NOT_BS_FOLDER"); }
|
||||
|
||||
const originalPath = await this.localVersionService.getVersionPath(rawBsVersion);
|
||||
let destPath = originalPath;
|
||||
let folderExist = this.utils.pathExist(destPath);
|
||||
let i = 0;
|
||||
|
||||
while(folderExist){
|
||||
i++;
|
||||
destPath = `${originalPath} (${i})`;
|
||||
folderExist = this.utils.pathExist(destPath);
|
||||
}
|
||||
const destPath = this.getPathNotAleardyExist(await this.localVersionService.getVersionPath(rawBsVersion));
|
||||
|
||||
await copy(path, destPath, {dereference: true});
|
||||
|
||||
@@ -197,7 +209,7 @@ export interface DownloadInfo {
|
||||
|
||||
export interface DownloadEvent{
|
||||
type: DownloadEventType,
|
||||
data?: unknown,
|
||||
data?: unknown
|
||||
}
|
||||
|
||||
export type DownloadEventType = "[Password]" | "[Guard]" | "[2FA]" | "[Progress]" | "[Validated]" | "[Finished]" | "[AlreadyDownloading]" | "[Error]" | "[Warning]" | "[SteamID]" | "[Exit]" | "[NoInternet]";
|
||||
|
||||
@@ -41,13 +41,11 @@ export function BsVersionItem(props: {version: BSVersion}) {
|
||||
)
|
||||
}
|
||||
|
||||
const cancel = () => {
|
||||
const versionDownload = downloaderService.currentBsVersionDownload$.value;
|
||||
downloaderService.cancelDownload().then(async res => {
|
||||
if(!res.success){ return; }
|
||||
if(!downloaderService.isVerification){
|
||||
bsUninstallerService.uninstall(versionDownload).then(res => res && verionManagerService.askInstalledVersions());
|
||||
}
|
||||
const cancel = () => {
|
||||
const versionDownload = downloaderService.currentBsVersionDownload$.value;
|
||||
downloaderService.cancelDownload().then(async res => {
|
||||
if(!res.success){ return; }
|
||||
bsUninstallerService.uninstall(versionDownload).then(res => res && verionManagerService.askInstalledVersions());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ export function AvailableVersionsList() {
|
||||
|
||||
const startDownload = () => {
|
||||
setDownloading(() => true)
|
||||
bsDownloaderService.download(versionSelected, versionManagerService.isVersionInstalled(versionSelected)).finally(() => {
|
||||
bsDownloaderService.download(versionSelected).finally(() => {
|
||||
setDownloading(() => false);
|
||||
});
|
||||
}
|
||||
@@ -91,7 +91,7 @@ export function AvailableVersionsList() {
|
||||
<AnimatePresence>
|
||||
{ versionSelected && !downloading && (
|
||||
<motion.div initial={{y:"150%"}} animate={{y:"0%"}} exit={{y:"150%"}} className="absolute bottom-5" onClick={startDownload}>
|
||||
<BsmButton text={versionManagerService.isVersionInstalled(versionSelected) ? "misc.verify" : "misc.download"} className="relative text-gray-800 dark:text-gray-100 rounded-md text-3xl font-bold italic tracking-wide px-3 pb-2 pt-1 shadow-md shadow-black"/>
|
||||
<BsmButton text="misc.download" className="relative text-gray-800 dark:text-gray-100 rounded-md text-3xl font-bold italic tracking-wide px-3 pb-2 pt-1 shadow-md shadow-black"/>
|
||||
</motion.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
|
||||
@@ -25,8 +25,6 @@ export class BsDownloaderService{
|
||||
private readonly notificationService: NotificationService;
|
||||
private readonly linkOpener: LinkOpenerService;
|
||||
|
||||
private _isVerification: boolean = false;
|
||||
|
||||
public readonly currentBsVersionDownload$: BehaviorSubject<BSVersion> = new BehaviorSubject(null);
|
||||
public readonly downloadProgress$: BehaviorSubject<number> = new BehaviorSubject(0);
|
||||
public readonly selectedBsVersion$: BehaviorSubject<BSVersion> = new BehaviorSubject(null);
|
||||
@@ -71,10 +69,15 @@ export class BsDownloaderService{
|
||||
this.ipcService.sendLazy('bs-download.[2FA]', {args: res.data});
|
||||
});
|
||||
|
||||
this.ipcService.watch<BSVersion>("start-download-version").subscribe(res => {
|
||||
this.currentBsVersionDownload$.next(res.data);
|
||||
});
|
||||
|
||||
this.currentBsVersionDownload$.subscribe(version => {
|
||||
if(version){ this.bsVersionManager.setInstalledVersions([...this.bsVersionManager.installedVersions$.value, version]); }
|
||||
else{ this.bsVersionManager.askInstalledVersions(); }
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private resetDownload(): void{
|
||||
@@ -91,7 +94,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>>{
|
||||
public async download(bsVersion: BSVersion, isFirstCall = true): Promise<IpcResponse<DownloadEvent>>{
|
||||
if(isFirstCall && !this.progressBarService.require()){ return {success: false}; }
|
||||
|
||||
if(isFirstCall && !(await this.isDotNet6Installed())){
|
||||
@@ -111,7 +114,6 @@ export class BsDownloaderService{
|
||||
}
|
||||
|
||||
this.progressBarService.show(this.downloadProgress$);
|
||||
this._isVerification = !!isVerification;
|
||||
|
||||
let promise;
|
||||
if(!this.authService.sessionExist()){
|
||||
@@ -127,25 +129,22 @@ export class BsDownloaderService{
|
||||
promise = this.ipcService.send<DownloadEvent>('bs-download.start', {args: {bsVersion, username: this.authService.getSteamUsername()}});
|
||||
}
|
||||
|
||||
this.currentBsVersionDownload$.next(bsVersion);
|
||||
|
||||
let res = await promise;
|
||||
|
||||
if(res.data?.type === "[Password]"){
|
||||
this.authService.deleteSteamSession();
|
||||
res = await this.download(bsVersion, isVerification, false);
|
||||
res = await this.download(bsVersion, false);
|
||||
}
|
||||
|
||||
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}); }
|
||||
if(res.success && isFirstCall){ this.notificationService.notifySuccess({title: "notifications.bs-download.success.titles.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;
|
||||
}
|
||||
|
||||
public get isDownloading(): boolean{ return !!this.currentBsVersionDownload$.value; }
|
||||
public get isVerification(): boolean{ return this._isVerification; }
|
||||
|
||||
public async getInstallationFolder(): Promise<string>{
|
||||
const res = await this.ipcService.send<string>("bs-download.installation-folder");
|
||||
|
||||
Reference in New Issue
Block a user