From 65c52cf1cc7e773cdf3e9460e2ba9c7a800db9ae Mon Sep 17 00:00:00 2001 From: TudbuT Date: Mon, 14 Oct 2024 03:51:45 +0200 Subject: [PATCH] fix SIGBUS --- Loader/src/main/java/de/com/baseband/launcher/Loader.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Loader/src/main/java/de/com/baseband/launcher/Loader.java b/Loader/src/main/java/de/com/baseband/launcher/Loader.java index 44478ce..94ac76c 100644 --- a/Loader/src/main/java/de/com/baseband/launcher/Loader.java +++ b/Loader/src/main/java/de/com/baseband/launcher/Loader.java @@ -392,9 +392,14 @@ public class Loader implements Util { InputStream stream = urlStream; if(filename != null) { byte[] bytes = new StreamReader(stream).readAllAsBytes(); - try(FileOutputStream os = new FileOutputStream(filename)) { + try(FileOutputStream os = new FileOutputStream(filename + ".tmp")) { os.write(bytes); } catch (IOException ignored) { } + Runtime.getRuntime().addShutdownHook(new Thread(() -> { + File f = new File(filename); + f.delete(); + new File(filename + ".tmp").renameTo(f); + })); stream = new ByteArrayInputStream(bytes); } ZipInputStream jar = new ZipInputStream(stream);