From 636177e1169b60d5339e6f6bac1089f8f447c34a Mon Sep 17 00:00:00 2001 From: nikky Date: Sun, 1 Aug 2021 10:34:25 +0200 Subject: [PATCH] fix when phase reboot is used via old jar --- .../kotlin/voodoo/multimc/InstallMultiMCCommand.kt | 2 +- .../src/main/kotlin/voodoo/multimc/Installer.kt | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/multimc/installer/src/main/kotlin/voodoo/multimc/InstallMultiMCCommand.kt b/multimc/installer/src/main/kotlin/voodoo/multimc/InstallMultiMCCommand.kt index a8a4c5cf..9347ce66 100644 --- a/multimc/installer/src/main/kotlin/voodoo/multimc/InstallMultiMCCommand.kt +++ b/multimc/installer/src/main/kotlin/voodoo/multimc/InstallMultiMCCommand.kt @@ -44,5 +44,5 @@ class InstallMultiMCCommand: CliktCommand( } enum class Phase { - PRE, POST + PRE, POST, REBOOT } diff --git a/multimc/installer/src/main/kotlin/voodoo/multimc/Installer.kt b/multimc/installer/src/main/kotlin/voodoo/multimc/Installer.kt index b97cd820..8e694b42 100644 --- a/multimc/installer/src/main/kotlin/voodoo/multimc/Installer.kt +++ b/multimc/installer/src/main/kotlin/voodoo/multimc/Installer.kt @@ -74,7 +74,7 @@ object Installer { currentJarFile.copyTo(voodooFolder.resolve("multimc-installer.jar"), overwrite = true) exitProcess(0) } - Phase.PRE -> { + Phase.PRE, Phase.REBOOT -> { // always copy current jar to post.jar val postFile = voodooFolder.resolve("post.jar") if(postFile.exists()) { @@ -106,7 +106,8 @@ object Installer { } else { postFile.download(installerUrl, cacheHome) } - val newFile = cacheHome.resolve("tmp.jar") + val newFile = cacheHome.resolve("tmp-${newSha256}.jar") + newFile.delete() postFile.copyTo(newFile, overwrite = true) return newFile } @@ -228,7 +229,10 @@ object Installer { "--mc", minecraftDir.path, "--phase", - phase.toString() + when(phase) { + Phase.REBOOT -> Phase.PRE + else -> phase + }.toString() ) logger.info { "Executing ${args.joinToString()}" }