diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/LauncherRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/LauncherRequest.java index adefd1cc..e451547b 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/LauncherRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/LauncherRequest.java @@ -1,6 +1,8 @@ package pro.gravit.launcher.request.update; import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; @@ -25,6 +27,9 @@ public final class LauncherRequest extends Request impleme public int launcher_type = EXE_BINARY ? 2 : 1; @LauncherAPI public static final Path BINARY_PATH = IOHelper.getCodeSource(Launcher.class); + + @LauncherAPI + public static final Path C_BINARY_PATH = BINARY_PATH.getParent().resolve(IOHelper.getFileName(BINARY_PATH) + ".tmp"); @LauncherAPI public static final boolean EXE_BINARY = IOHelper.hasExtension(BINARY_PATH, "exe"); @@ -52,7 +57,11 @@ public static void update(LauncherRequestEvent result) throws IOException { }*/ try { ListDownloader downloader = new ListDownloader(); - downloader.downloadOne(result.url, BINARY_PATH); + downloader.downloadOne(result.url, C_BINARY_PATH); + try (InputStream in = IOHelper.newInput(C_BINARY_PATH)) { + IOHelper.transfer(in, BINARY_PATH); + } + Files.deleteIfExists(C_BINARY_PATH); } catch (Throwable e) { LogHelper.error(e); }