From d74008b10924b368166935435df1b262ebec4996 Mon Sep 17 00:00:00 2001 From: MathieuG-P <40181755+Zagrios@users.noreply.github.com> Date: Sat, 18 Nov 2023 12:51:49 +0100 Subject: [PATCH] [bugfix] Unable to start Oculus version after moving installation path --- .../bs-launcher/oculus-launcher.service.ts | 27 +++++++++++-------- .../services/installation-location.service.ts | 4 +-- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/main/services/bs-launcher/oculus-launcher.service.ts b/src/main/services/bs-launcher/oculus-launcher.service.ts index 8af2b111..2cf7f7e8 100644 --- a/src/main/services/bs-launcher/oculus-launcher.service.ts +++ b/src/main/services/bs-launcher/oculus-launcher.service.ts @@ -51,28 +51,33 @@ export class OculusLauncherService extends AbstractLauncherService implements St throw new Error("Oculus library not found, deleteBsSymlinks"); } - const libContents = await readdir(oculusLibPath, { withFileTypes: true}); - const symlinks = (await Promise.all(libContents.map(async dirent => { - return (await lstat(path.join(oculusLibPath, dirent.name))).isSymbolicLink() ? dirent : null; + const libContents = await readdir(oculusLibPath); + const symlinks = (await Promise.all(libContents.map(async dir => { + return (await lstat(path.join(oculusLibPath, dir))).isSymbolicLink() ? dir : null; }))).filter(Boolean); - const bsSymlinks = symlinks.filter(dirent => dirent.name.startsWith(OCULUS_BS_DIR)); - const versionsFolderPath = await this.pathsService.versionsDirectory(); + log.info("Symlinks found in Oculus library", symlinks); + + const bsSymlinks = symlinks.filter(dirent => dirent.startsWith(OCULUS_BS_DIR)); - // get only symlinks created by BSM (with metadata.config) const bsmSymlinks = (await Promise.all(bsSymlinks.map(async symlink => { - const symlinkPath = path.join(oculusLibPath, symlink.name); - const targetPath = await readlink(symlinkPath).catch(err => { log.error(err); return undefined; }); + const symlinkPath = path.join(oculusLibPath, symlink); + const targetPath = await readlink(symlinkPath).catch(err => log.error(err)); + + log.info("Oculus Symlink", symlink, "target", targetPath); if(!targetPath){ return null; } - if(!targetPath.startsWith(versionsFolderPath)){ return null; } + + const bsmVersionsDir = path.join(this.pathsService.INSTALLATION_FOLDER, this.pathsService.VERSIONS_FOLDER); + + if(!targetPath.includes(bsmVersionsDir)){ return null; } return symlink; }))).filter(Boolean); await Promise.all(bsmSymlinks.map(symlink => { - log.info("Deleting symlink", symlink.name); - return unlink(path.join(oculusLibPath, symlink.name)); + log.info("Delete symlink", symlink); + return unlink(path.join(oculusLibPath, symlink)); })); } diff --git a/src/main/services/installation-location.service.ts b/src/main/services/installation-location.service.ts index 2d32ee34..7445ba2a 100644 --- a/src/main/services/installation-location.service.ts +++ b/src/main/services/installation-location.service.ts @@ -13,8 +13,8 @@ export class InstallationLocationService { return InstallationLocationService.instance; } - private readonly INSTALLATION_FOLDER = "BSManager"; - private readonly VERSIONS_FOLDER = "BSInstances"; + public readonly INSTALLATION_FOLDER = "BSManager"; + public readonly VERSIONS_FOLDER = "BSInstances"; private readonly SHARED_CONTENT_FOLDER = "SharedContent";