From 3598bc6b52c6910d6f0428474e314152c1a770e9 Mon Sep 17 00:00:00 2001 From: shuabritze <163845127+shuabritze@users.noreply.github.com> Date: Sat, 22 Feb 2025 23:41:34 +0200 Subject: [PATCH] fix: Mod migration --- package.json | 2 +- src/mod-download.ts | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 636d893..f5e5015 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mushroom-launcher", "productName": "Mushroom Launcher", - "version": "1.2.1", + "version": "1.2.2", "description": "Mushhroom Game Launcher", "main": ".vite/build/main.js", "private": true, diff --git a/src/mod-download.ts b/src/mod-download.ts index 1339d2c..457dad6 100644 --- a/src/mod-download.ts +++ b/src/mod-download.ts @@ -13,14 +13,19 @@ export const GetModDirectory = () => { const appDataPath = app.getPath("userData"); // Migrate old mods - if (fs.existsSync(path.join(path.dirname(process.execPath), "../mods"))) { - fs.copyFileSync( - path.join(path.dirname(process.execPath), "../mods"), + const oldDir = path.join( + path.dirname(process.execPath), + app.isPackaged ? "../mods" : "../../../mods", + ); + if (fs.existsSync(oldDir)) { + // Copy the old mods directory to the new location + fs.cpSync(oldDir, path.join(appDataPath, "mods"), { recursive: true }); + fs.rmSync(oldDir, { recursive: true }); + + logger.info( + "Migrated old mods to new location: ", path.join(appDataPath, "mods"), ); - fs.rmdirSync(path.join(path.dirname(process.execPath), "../mods")); - - logger.info("Migrated old mods to new location: ", path.join(appDataPath, "mods")); } const dir = path.join(appDataPath, "mods");