From aec9dd062887aa9d6195644e170e66b757e5840a Mon Sep 17 00:00:00 2001 From: silentrald Date: Sun, 8 Dec 2024 23:47:16 +0800 Subject: [PATCH] [feat-76] fixed issue where copying dll files to non-existent folder path --- src/main/services/mods/bs-mods-manager.service.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/services/mods/bs-mods-manager.service.ts b/src/main/services/mods/bs-mods-manager.service.ts index aa9216df..6185595d 100644 --- a/src/main/services/mods/bs-mods-manager.service.ts +++ b/src/main/services/mods/bs-mods-manager.service.ts @@ -11,7 +11,7 @@ import { deleteFolder, pathExist, Progression, unlinkPath } from "../../helpers/ import { lastValueFrom, Observable } from "rxjs"; import recursiveReadDir from "recursive-readdir"; import { sToMs } from "../../../shared/helpers/time.helpers"; -import { copyFile, pathExistsSync } from "fs-extra"; +import { copyFile, ensureDir, pathExistsSync } from "fs-extra"; import { CustomError } from "shared/models/exceptions/custom-error.class"; import { popElement } from "shared/helpers/array.helpers"; import { LinuxService } from "../linux.service"; @@ -325,9 +325,13 @@ export class BsModsManagerService { const extensionName = path.extname(modPath).toLowerCase(); if (extensionName === ".dll") { - log.info("Copying", `${modPath}`, "to", `"${destination}"`); - const filename = path.basename(modPath, ".dll"); - const copied = await copyFile(modPath, path.join(destination, filename)) + const filename = path.basename(modPath); + // Defaultly copy the ".dll" to the "IPA/Pending/Plugins" folder + const fileFolder = path.join(destination, ModsInstallFolder.PLUGINS); + + log.info("Copying", `${modPath}`, "to", `"${fileFolder}"`); + await ensureDir(fileFolder); + const copied = await copyFile(modPath, path.join(fileFolder, filename)) .then(() => true) .catch(error => { log.warn("Could not copy", `"${modPath}"`, error); @@ -397,7 +401,6 @@ export class BsModsManagerService { if (modFiles.length > 0) { ++modsInstalledCount; modFilesCount += modFiles.length; - log.info(modFiles); externalMod.name = path.basename(modPath, path.extname(modPath)); externalMod.files = modFiles;