From 4ca7e74996da2cd24c6128978d3743416b763352 Mon Sep 17 00:00:00 2001 From: Christopher Schnick Date: Wed, 13 Mar 2024 06:36:03 +0100 Subject: [PATCH] Improve melter error message --- .../pdxu/app/util/integration/RakalyHelper.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pdxu-app/src/main/java/com/crschnick/pdxu/app/util/integration/RakalyHelper.java b/pdxu-app/src/main/java/com/crschnick/pdxu/app/util/integration/RakalyHelper.java index 5e7748ee..548a469a 100644 --- a/pdxu-app/src/main/java/com/crschnick/pdxu/app/util/integration/RakalyHelper.java +++ b/pdxu-app/src/main/java/com/crschnick/pdxu/app/util/integration/RakalyHelper.java @@ -4,6 +4,7 @@ import com.crschnick.pdxu.app.savegame.SavegameContext; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; public class RakalyHelper { @@ -15,6 +16,7 @@ public static boolean shouldShowButton(SavegameContext context) { public static byte[] toMeltedPlaintext(Path file) throws Exception { var melter = PdxuInstallation.getInstance().getRakalyExecutable(); + check(melter); var proc = new ProcessBuilder( melter.toString(), "melt", @@ -35,8 +37,10 @@ public static byte[] toMeltedPlaintext(Path file) throws Exception { } public static byte[] toEquivalentPlaintext(Path file) throws Exception { + var melter = PdxuInstallation.getInstance().getRakalyExecutable(); + check(melter); var proc = new ProcessBuilder( - PdxuInstallation.getInstance().getRakalyExecutable().toString(), + melter.toString(), "melt", "--unknown-key", "stringify", "--retain", @@ -54,4 +58,10 @@ public static byte[] toEquivalentPlaintext(Path file) throws Exception { return b; } + + private static void check(Path file) throws IOException { + if (!Files.exists(file)) { + throw new IOException("Ironman melter executable " + file + " is missing. This is usually caused by Windows Defender or another AntiVirus program removing the melter executable because it thinks it's malicious.\n\nYou can try deleting %LOCALAPPDATA%\\Programs\\Pdx-Unlimiter\\app\\ and relaunching pdxu. That should trigger a new download. If the file then gets removed again, you probably have to add an exception to your antivirus."); + } + } }