Skip to content

Commit

Permalink
Improve melter error message
Browse files Browse the repository at this point in the history
  • Loading branch information
crschnick committed Mar 13, 2024
1 parent fbc0fe4 commit 4ca7e74
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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.");
}
}
}

0 comments on commit 4ca7e74

Please sign in to comment.