no more verification in available versions list

This commit is contained in:
MathieuG-P
2023-01-24 22:55:25 +01:00
parent bbd26d1c12
commit 1cfef9f607
4 changed files with 39 additions and 30 deletions
+24 -12
View File
@@ -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]";