Merge pull request #284 from Zagrios/hotfix/nothing-happens-launch-unexisting-version-from-shortcut

[hotflix] fix nothing happens when launching a version from shortcut that no longer exist
This commit is contained in:
MathieuG-P
2023-07-16 20:50:01 +02:00
committed by GitHub
2 changed files with 13 additions and 4 deletions
+10 -4
View File
@@ -51,7 +51,7 @@ export class BSLauncherService {
this.bsmProtocolService.on("launch", link => {
log.info("Launch from bsm protocol", link.toString());
const shortcutParams = objectFromEntries(link.searchParams.entries()) as ShortcutParams;
this.openShortcutLaunchWindow(shortcutParams);
this.openShortcutLaunchWindow(shortcutParams).catch(log.error);
});
}
@@ -293,12 +293,18 @@ export class BSLauncherService {
private async openShortcutLaunchWindow(launchOptions: ShortcutParams): Promise<void>{
const launchOption = this.shortcutParamsToLaunchOption(launchOptions);
const bsPath = await this.localVersionService.getInstalledVersionPath(launchOption.version);
const bsPath: string = await (async () => {
const bsPath = await this.localVersionService.getInstalledVersionPath(launchOption.version);
return bsPath ?? this.localVersionService.getVersionPath(launchOption.version);
})().catch(e => {
log.error(e);
return null;
});
launchOption.version = await this.localVersionService.getVersionOfBSFolder(bsPath, {
launchOption.version = (await this.localVersionService.getVersionOfBSFolder(bsPath, {
steam: launchOption.version.steam,
oculus: launchOption.version.oculus,
});
})) ?? launchOption.version;
launchOption.version = {...(await this.remoteVersion.getVersionDetails(launchOption.version.BSVersion)), ...launchOption.version};
@@ -84,6 +84,9 @@ export class BSLocalVersionService {
oculus?: boolean;
}
): Promise<BSVersion>{
if(!bsPath){ return null; }
const versionFilePath = path.join(bsPath, 'Beat Saber_Data', 'globalgamemanagers');
const folderVersion = await this.getVersionFromGlobalGameManagerFile(versionFilePath);