[bugfix] fixed : unable to install BSIPA if BSIPA path was containing spaces + wrong translation when bsipa was throwing errors

This commit is contained in:
MathieuG-P
2024-07-21 14:53:49 +02:00
parent 1c0cfb6b89
commit 709105b9f4
2 changed files with 17 additions and 12 deletions
@@ -16,6 +16,7 @@ import { extractZip } from "../../helpers/zip.helpers";
import recursiveReadDir from "recursive-readdir";
import { sToMs } from "../../../shared/helpers/time.helpers";
import { ensureDir } from "fs-extra";
import { CustomError } from "shared/models/exceptions/custom-error.class";
export class BsModsManagerService {
private static instance: BsModsManagerService;
@@ -147,7 +148,7 @@ export class BsModsManagerService {
return new Promise<boolean>(resolve => {
const cmd = process.platform === 'linux'
? `screen -dmS "BSIPA" dotnet ${ipaPath} ${args.join(" ")}` // Must run through screen, otherwise BSIPA tries to move console cursor and crashes.
: `${ipaPath} ${args.join(" ")}`;
: `"${ipaPath}" ${args.join(" ")}`;
log.info("START IPA PROCESS", cmd);
const processIPA = spawn(cmd, { cwd: versionPath, detached: true, shell: true });
@@ -157,6 +158,10 @@ export class BsModsManagerService {
resolve(false)
}, sToMs(30));
processIPA.stderr.on("data", data => {
log.error("IPA process stderr", data.toString());
})
processIPA.once("exit", code => {
clearTimeout(timemout);
if (code === 0) {
@@ -167,7 +172,6 @@ export class BsModsManagerService {
resolve(false);
});
});
}
@@ -339,7 +343,7 @@ export class BsModsManagerService {
public async installMods(mods: Mod[], version: BSVersion): Promise<InstallModsResult> {
if (!mods?.length) {
throw "no-mods";
throw CustomError.fromError(new Error("No mods to install"), "no-mods");
}
const deps = await this.resolveDependencies(mods, version);
@@ -359,7 +363,7 @@ export class BsModsManagerService {
return false;
});
if (!installed) {
throw "cannot-install-bsipa";
throw CustomError.fromError(new Error("Unable to install BSIPA"), "cannot-install-bsipa");
}
}
@@ -375,7 +379,7 @@ export class BsModsManagerService {
public async uninstallMods(mods: Mod[], version: BSVersion): Promise<UninstallModsResult> {
if (!mods?.length) {
throw "no-mods";
throw CustomError.fromError(new Error("No mods to uninstall"), "no-mods");
}
this.nbModsToUninstall = mods.length;
@@ -395,7 +399,7 @@ export class BsModsManagerService {
const mods = await this.getInstalledMods(version);
if (!mods?.length) {
throw "no-mods";
throw CustomError.fromError(new Error("This version has to mods to uninstall"), "no-mods");
}
this.nbModsToUninstall = mods.length;
@@ -11,6 +11,7 @@ import { NotificationType } from "../../shared/models/notification/notification.
import { OsDiagnosticService } from "./os-diagnostic.service";
import { ProgressBarService } from "./progress-bar.service";
import { NotificationService } from "./notification.service";
import { CustomError } from "shared/models/exceptions/custom-error.class";
export class BsModsManagerService {
private static instance: BsModsManagerService;
@@ -79,8 +80,8 @@ export class BsModsManagerService {
const desc = `notifications.mods.install-mods.msg.${isFullyInstalled ? "success" : "warning"}`;
this.notifications.notify({ type: isFullyInstalled ? NotificationType.SUCCESS : NotificationType.WARNING, title, desc, duration: this.NOTIFICATION_DURATION });
}).catch(e => {
this.notifications.notifyError({ title: "notifications.types.error", desc: `notifications.mods.install-mods.msg.errors.${e}`, duration: this.NOTIFICATION_DURATION });
}).catch((e: CustomError) => {
this.notifications.notifyError({ title: "notifications.types.error", desc: `notifications.mods.install-mods.msg.errors.${e?.code}`, duration: this.NOTIFICATION_DURATION });
}).finally(() => {
this.isInstalling$.next(false);
this.progressBar.hide();
@@ -104,8 +105,8 @@ export class BsModsManagerService {
return lastValueFrom(this.ipcService.sendV2("uninstall-mods", { mods: [mod], version })).then(() => {
this.notifications.notifySuccess({ title: "notifications.mods.uninstall-mod.titles.success", duration: this.NOTIFICATION_DURATION });
}).catch(e => {
this.notifications.notifyError({ title: "notifications.types.error", desc: `notifications.mods.uninstall-mod.msg.errors.${e}`, duration: this.NOTIFICATION_DURATION });
}).catch((e: CustomError) => {
this.notifications.notifyError({ title: "notifications.types.error", desc: `notifications.mods.uninstall-mod.msg.errors.${e?.code}`, duration: this.NOTIFICATION_DURATION });
}).finally(() => {
this.isUninstalling$.next(false);
this.progressBar.hide();
@@ -129,8 +130,8 @@ export class BsModsManagerService {
this.isUninstalling$.next(true);
return lastValueFrom(this.ipcService.sendV2("uninstall-all-mods", version)).then(() => {
this.notifications.notifySuccess({ title: "notifications.mods.uninstall-all-mods.titles.success", desc: "notifications.mods.uninstall-all-mods.msg.success", duration: this.NOTIFICATION_DURATION });
}).catch(e => {
this.notifications.notifyError({ title: "notifications.types.error", desc: `notifications.mods.uninstall-all-mods.msg.errors.${e}`, duration: this.NOTIFICATION_DURATION });
}).catch((e: CustomError) => {
this.notifications.notifyError({ title: "notifications.types.error", desc: `notifications.mods.uninstall-all-mods.msg.errors.${e?.code}`, duration: this.NOTIFICATION_DURATION });
}).finally(() => {
this.isUninstalling$.next(false);
this.progressBar.hide();